DaLiMan Posted February 15, 2005 Share Posted February 15, 2005 Hi, I want to compare 2 files for a number and if a number doesn't exist store this line in a separate file for later use. So I thought I'd read the file to a line and compare it, but in the new file the value could be altered so it would not be found even though it is still there. So I thought of reading only the first 6 characters and compare this with the first 6 of the second file. But I cannot even get that straight. Can someone please help me? Below an example how a file could look like: CODE DESCRIPTION VALUE DATE 101010 SOME TEKST 1000000 20012005 101020 SOME TEKST 1100000 20012005 Any other ideas of doing this would also be much appreciated. Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 15, 2005 Share Posted February 15, 2005 i did stuff like this with a menu program.use a for .. to.. next to read every line into a array.then split it into array[*], after this you can just check the numbers or search for sub strings *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
DaLiMan Posted February 15, 2005 Author Share Posted February 15, 2005 i did stuff like this with a menu program.use a for .. to.. next to read every line into a array.then split it into array[*], after this you can just check the numbers or search for sub strings<{POST_SNAPBACK}>Thanks,I was on my way doing that, but because of typos it wouldn't work.Since you also said doing it this way I had another good look at it and figured it out. Compares about 1700 lines in just under 10 sec. which for me is fast enough.Here's a copy of it for anyone who's interested:expandcollapse popup#include <file.au3> Global $Versie = "1.0.0.0" Global $AARRAY Global $AARRAY2 Global $AARRAY3 Global $Log1 = @TempDir & "solarconcomp1.txt" Global $Log2 = "C:\solarconcomp.txt" Global $File1 = "P:\Solar\Solarcon\solarcon.txt" Global $File2 = "C:\Program Files\VCG\Files\solarcon.txt" $begin = TimerInit() ProgressOn("Progress Meter VCG's", "Comparing solarcon files", "0 percent",0,0) FileDelete($Log1) FileDelete($Log2) If _FileReadToArray($File1, $AARRAY) Then For $X = 1 To $AARRAY[0] $Percent = Round(($X / $AARRAY[0]) * 50,2) ProgressSet($Percent, $Percent & " % gereed" & @CRLF & "Nummer : " & $X & " van " & $AARRAY[0], "Extracting VCG from solarcon.txt" ) $AARRAY2 = StringLeft($AARRAY[$X], 6) LogFileWrite($Log1,$AARRAY2 & @CRLF) Next Else ; returncode was 0 so the function reported that the file doesn't exist MsgBox(0, "Error", $File1 &@CRLF& "not found!!!") EndIf $AARRAY3 = FileRead($Log1, FileGetSize($Log1)) If _FileReadToArray($File2, $AARRAY) Then For $X = 1 To $AARRAY[0] $Percent = Round((($X / $AARRAY[0]) * 50)+50,2) ProgressSet($Percent, $Percent & " % done" & @CRLF & "Nummer : " & $X & " van " & $AARRAY[0], "Comparing solarcon files") $AARRAY2 = StringLeft($AARRAY[$X], 6) If StringInStr($AARRAY3, $AARRAY2) = 0 Then LogFileWrite($Log2,$AARRAY[$X] & @CRLF) EndIf Next Else ; returncode was 0 so the function reported that the file doesn't exist MsgBox(0, "Error", $File2 &@CRLF& "not found!!!") EndIf $dif = Round(TimerDiff($begin)/1000,2) ProgressSet(100, $Percent & " % done" & @CRLF & "In : " & $dif & " seconden.", "Opening files") Run(@ComSpec & " /c " & $File1, "", @SW_HIDE) Sleep(250) Run(@ComSpec & " /c " & $Log2, "", @SW_HIDE) Sleep(1500) ProgressOff() Exit Func LogFileWrite($filename, $text) While 1 If 1 = FileWrite($filename, $text) Then ExitLoop Sleep(300) Wend Return EndFuncGreetings. 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