Sleiman Posted March 15, 2004 Share Posted March 15, 2004 I have 2 files. One contains a 6 characters employee number. The second file contains a information about the employee. What I need is a way to find out if for each employee number, if there is a hit in the second file. End result would be: Emp# Hit 123456 Y 123457 N 123458 Y I need to loop through the employee file and for each record, search the second file for the occurance of employee number. Looking forward for some ideas, Seiman Link to comment Share on other sites More sharing options...
ezzetabi Posted March 15, 2004 Share Posted March 15, 2004 And what is the problem? Link to comment Share on other sites More sharing options...
Sleiman Posted March 15, 2004 Author Share Posted March 15, 2004 I am looking for a script sample on how to do it! Link to comment Share on other sites More sharing options...
Developers Jos Posted March 15, 2004 Developers Share Posted March 15, 2004 here you have an example that does more or less what you want... You still need to have a look at the match test ... $FILE1 = "lookup.txt" $FILE2 = "emprec.txt" $FILE3 = "match.txt" $FH2=FileOpen("emprec.txt",0) If $FH2 = -1 Then MsgBox(0, "Error", "Unable to open:"& $FILE2) Exit EndIf While 1 $LINE2 = FileReadLine($FH2) If @error = -1 Then ExitLoop $FH1=FileOpen($FILE1,0) If $FH1 = -1 Then MsgBox(0, "Error", "Unable to open :" & $FILE1) Exit EndIf While 1 $LINE1 = FileReadLine($FH1) If @error = -1 Then FileWriteLine($FILE3,$LINE2 & " N") ExitLoop EndIf ; put here your match test If StringMid($LINE1,4,10) = $LINE2 Then FileWriteLine($FILE3,$LINE2 & " Y") ExitLoop EndIf Wend FileClose($FH1) Wend FileClose($FH2) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Gene Posted March 15, 2004 Share Posted March 15, 2004 I have 2 files. One contains a 6 characters employee number. The second file contains a information about the employee.What I need is a way to find out if for each employee number, if there is a hit in the second file. End result would be:Emp# Hit123456 Y123457 N123458 YI need to loop through the employee file and for each record, search the second file for the occurance of employee number.Looking forward for some ideas,SeimanH'mmn, how big are the files? How big are they ever likely to be?If they are small enough to load at once, the compairison processing c/would be different from reading a line at a time, and MUCH faster.Gene [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right... Link to comment Share on other sites More sharing options...
Sleiman Posted March 18, 2004 Author Share Posted March 18, 2004 Thank you MassSpammer, your recommendation work very well. Sleiman Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now