PalmmieWP Posted December 21, 2017 Share Posted December 21, 2017 Hello, Im a new comer. I want to know the way, how to read file and compare number value between 2 file. file is have text and value but number have 2-3 digit. Link to comment Share on other sites More sharing options...
Astralhead Posted December 21, 2017 Share Posted December 21, 2017 exapmple from autoit help .. Local $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in 1 character at a time until the EOF is reached While 1 Local $chars = FileRead($file, 1) If @error = -1 Then ExitLoop MsgBox(0, "Char read:", $chars) WEnd FileClose($file) you could as well use it like this: Local $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf Local $text = FileRead($file) MsgBox(0, "Full Text:", $chars) FileClose($file) if "fileread" doesn't suit your neads you could take a look at FileReadLine ( "filehandle/filename" [, line] ) in this case Local $line = FileReadLine($file) MsgBox(0, "Line read:", $line) ;load line 3 Local $line = FileReadLine($file,3) MsgBox(0, "Line 3 contains:", $line) good luck! Link to comment Share on other sites More sharing options...
kylomas Posted December 21, 2017 Share Posted December 21, 2017 Please provide an example of the data to compare. PalmmieWP 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
PalmmieWP Posted December 26, 2017 Author Share Posted December 26, 2017 This file to compare sample1.txt sample2.txt Link to comment Share on other sites More sharing options...
Developers Jos Posted December 26, 2017 Developers Share Posted December 26, 2017 So you want to compare some values in these xml files in particular fields not just a value in a file. Why not start with properly explaining what you want to accomplish and what you have tried so far? Jos 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...
mikell Posted December 26, 2017 Share Posted December 26, 2017 As you don't specify the values to be checked here is a random try _Compare("sample1.txt", "sample2.txt", "G_RFTX_F2") Func _Compare($file1, $file2, $test) $txt1 = FileRead($file1) $txt2 = FileRead($file2) $value_1 = StringRegExpReplace($txt1, '(?s).*' & $test & '.*?ValNum="([\d.]+).*', "$1") $value_2 = StringRegExpReplace($txt2, '(?s).*' & $test & '.*?ValNum="([\d.]+).*', "$1") Msgbox(0,"", $test & " values are :" & @crlf & @crlf & _ $value_1 & " in " & $file1 & @crlf & _ $value_2 & " in " & $file2) EndFunc #cs $txt1 = FileRead("sample1.txt") $txt2 = FileRead("sample2.txt") $test = "G_RFTX_F1" $G_RFTX_F1_1 = StringRegExpReplace($txt1, '(?s).*' & $test & '.*?ValNum="([\d.]+).*', "$1") $G_RFTX_F1_2 = StringRegExpReplace($txt2, '(?s).*' & $test & '.*?ValNum="([\d.]+).*', "$1") Msgbox(0,"", $test & " are :" & @crlf & @crlf & _ $G_RFTX_F1_1 & " (sample1)" & @crlf & _ $G_RFTX_F1_2 & " (sample2)") #ce PalmmieWP 1 Link to comment Share on other sites More sharing options...
PalmmieWP Posted January 8, 2018 Author Share Posted January 8, 2018 Thank you all 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