Jump to content
Sign in to follow this  
Awais

Finding A Name And It's Line Number In A Single File

Recommended Posts

Awais

How to find A Name And It's Line Number In A Single File  :geek:   o:)

Help Please 

Edited by Awais

Share this post


Link to post
Share on other sites
Melba23

Awais,

You have to know that is no where near enough information to expect sensible replies. What exactly do you mean by "Name"? What is the file structure? :huh:

Please give us a chance to help you by explaining your request in more detail. wink.png

M23

Edited by Melba23
21k!

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Awais

I have a simple text file

And i want to find a string

And then i want the line no of that string where it was

Thanks n advance

Share this post


Link to post
Share on other sites
Awais

My real problme is that

I want to save visa details in a file

Like passport no

Name of it's person

N it profession an so on then

In a single file

Then i wana find the record by it's name

How i do it

Share this post


Link to post
Share on other sites
guinness

Information like that shouldn't be stored in plaintext. Any professional knows that.

  • Like 1

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
Awais

i know that 

but anyway if we save like

passport no 11111     name father name ETC

passport no 111112     name2 father name ETC

passport no 111113    name3 father name ETC 

i want to find name3 

and it's line no 

Share this post


Link to post
Share on other sites
Awais

Right !

i am trying to find the whole record of a person using any method can you help me please ?

And There is no problme if It Find Duplicate Record 

Thus I want to find the all same name in a file using any structure ????

Edited by Awais

Share this post


Link to post
Share on other sites
jchd

If you don't use a robust storage container and insist on plaintext you're going to face gory issues sooner than later. You'd better choose something suited to the task right now.

How many records are you expecting in the long run?

Which queries are you going to need? Corollary: will you always expect a perfect match on names without any typo ever?

How many people, processes, distinct machines will update, query the data?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Awais

i want to find two basic record 

No One Passport Number Like 123456789

No Two Person Name Like Shaoib

Only Two Basic Information 

Please Help

Share this post


Link to post
Share on other sites
jchd

If you're doing serious work you should consider a database. AutoIt includes support for a simple but efficient database engine for local usage, SQLite, but also allows you to operate on almost all major client-server engines thru ADO (~ODBC).

Here's how your DB definition could look like:

CREATE TABLE "Visas" (
  "Passport" CHAR NOT NULL, 
  "Name" CHAR NOT NULL, 
  "Surname" CHAR, 
  "Profession" CHAR, 
  "Birthdate" CHAR, 
  "Birthplace" CHAR, 
  "WhateverElse" CHAR, 
  CONSTRAINT "" PRIMARY KEY ("Passport"));

CREATE INDEX "ixNameSurname" ON "Visas" ("Name", "Surname");

CREATE INDEX "ixBirthdate" ON "Visas" ("Birthdate");

Then you can insert, update, query the DB very easily and reliably.

E.g.

select * from visas where passport like '123456%';  -- returns rows having passport number starting with 123456

select * from visas where name like 'qadri' and surname like 'sho?b%';


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Exit

Just my two cents:

;~ prepare File
$handle = FileOpen(@ScriptFullPath & ".input.txt", 2)
FileWrite($handle, "passport no 11111     name father name ETC" & @CRLF & _
        "passport no 111112     name2 father name ETC" & @CRLF & _
        "passport no 111113    name3 father name ETC")
;~ ShellExecute(@ScriptFullPath&".input.txt")


;~ specify search string
$search = "name3"

RunWait('"' & @ComSpec & '" /c type ' & @ScriptFullPath & ".input.txt" & ' | find /N "' & $search & '" >' & @ScriptFullPath & '.result.txt', '', @SW_HIDE)
ShellExecute(@ScriptFullPath & ".result.txt")

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
jchd

Very simple and efficient way to shoot oneself in the foot or feet.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Jos

If one really has no programming or DB experience I would recommend using a simple straightforward Excel sheet with the right columns and use the standard Data/Filter option.

At least it is maintainable and you can put a basic security on it by password protecting it.

Jos.

  • Like 1

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
abberration

Jos, I think the Excel sheet with password protection is dangerous to suggest to someone who doesn't know what he's doing. If he holds other people's information with 40 bit encryption that can be cracked in seconds, then that gives him a false sense of security.

I would suggest using an _Crypt_EncryptData/_Crypt_DecryptData and writing/reading the data to an INI file. It would not be as good as a true database, but I think that would be something he could learn quickly and would be somewhat secure.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites
Jos

Jos, I think the Excel sheet with password protection is dangerous to suggest to someone who doesn't know what he's doing. If he holds other people's information with 40 bit encryption that can be cracked in seconds, then that gives him a false sense of security.

 

Hey, when the OP is prepared to put it in a simple TXT file for starters this is way better, but of course understand that it is far from bulletproof.

My main reason for proposing Excel was that the OP doesn't seem to have any knowledge about programming.

I would suggest using an _Crypt_EncryptData/_Crypt_DecryptData and writing/reading the data to an INI file. It would not be as good as a true database, but I think that would be something he could learn quickly and would be somewhat secure.

No sure how that would be any safer than what I proposed when the script is together with the INI. ;)

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
abberration

True, but it could be relatively safe if the INI file only holds encrypted data (which is what I meant to suggest) and he only has the compiled script with the INI file. The source code should not be stored on any computer that runs the program. Personally, I would keep the source code on an encrypted drive.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites
Jos

True, but it could be relatively safe if the INI file only holds encrypted data (which is what I meant to suggest) and he only has the compiled script with the INI file. The source code should not be stored on any computer that runs the program. Personally, I would keep the source code on an encrypted drive.

Still as unsafe as my proposal as the source is embedded in the compiled script.

Jos

  • Like 1

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
abberration

Jos, you are correct, of course. I hadn't considered that aspect.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites
Bert

What is the source of information you are searching? We are suggesting things and we have NO idea what he is searching. I know is is a txt file but where is it coming from? What is the formatting in this txt file? Can we see a sample of say 500 lines from this txt file?

  • Like 1

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×