Guillermo Posted October 20, 2005 Share Posted October 20, 2005 If I use this func to check a small file, it gives the right number of lines. If I use it to check a fairly big file (>18000 lines), it gives me a negative number with seven figures... Does anyone know what might be happening? Link to comment Share on other sites More sharing options...
seandisanti Posted October 20, 2005 Share Posted October 20, 2005 If I use this func to check a small file, it gives the right number of lines.If I use it to check a fairly big file (>18000 lines), it gives me a negative number with seven figures...Does anyone know what might be happening?could you post a copy of the file it's having issues with? Link to comment Share on other sites More sharing options...
Guillermo Posted October 20, 2005 Author Share Posted October 20, 2005 (edited) There you go! It's a MS EN-ES glossary available for download from their ftp. It was a .csv file, but I changed the ext to .txt.mybigfile.rar Edited October 20, 2005 by Guillermo Link to comment Share on other sites More sharing options...
seandisanti Posted October 20, 2005 Share Posted October 20, 2005 There you go!It's a MS EN-ES glossary available for download from their ftp.It was a .csv file, but I changed the ext to .txt.ok... couple of things...first i opened the file in notepad, hit control g and entered 999,999 so that the limit exceeded message would appear and the last line number 27,403 would be displayed. then i used the following code:#include<file.au3> $bf = FileOpen("c:\prueba.txt",0) $counter = 0 while 1 $line = FileReadLine($bf) if @error = -1 then ExitLoop $counter = $counter +1 WEnd MsgBox(0,"counter",$counter & " lines counted") $blah = _FileCountLines($bf) MsgBox(0,"countline output",$blah & @crlf & @error)the first message box that counts the number of times the script read a line, returned 37,709, the second message box returned 0 as a result (which the helpfile says indicates an error) but an @error of 0 also (helpfile indicates that if an error occurs with _FileCountLines() that @error will be set... i then opened the file in microsoft word (i was going to use the display all characters to see if there were multiple line breaks per line etc that could have led to my result being higher than notepad's. i was asked what kind of encoding to use to display the file, and i selected plain text, the text appeared with extra unprintable characters etc... so i opened as unicode and it worked fine... i'm thinking that the encoding of the file is what's causing the abnormal behavior. i'm going to open it as unicode, and resave as plain text, then run the script on it, and i expect to see correct results. Link to comment Share on other sites More sharing options...
seandisanti Posted October 20, 2005 Share Posted October 20, 2005 ok... couple of things...first i opened the file in notepad, hit control g and entered 999,999 so that the limit exceeded message would appear and the last line number 27,403 would be displayed. then i used the following code:#include<file.au3> $bf = FileOpen("c:\prueba.txt",0) $counter = 0 while 1 $line = FileReadLine($bf) if @error = -1 then ExitLoop $counter = $counter +1 WEnd MsgBox(0,"counter",$counter & " lines counted") $blah = _FileCountLines($bf) MsgBox(0,"countline output",$blah & @crlf & @error)the first message box that counts the number of times the script read a line, returned 37,709, the second message box returned 0 as a result (which the helpfile says indicates an error) but an @error of 0 also (helpfile indicates that if an error occurs with _FileCountLines() that @error will be set... i then opened the file in microsoft word (i was going to use the display all characters to see if there were multiple line breaks per line etc that could have led to my result being higher than notepad's. i was asked what kind of encoding to use to display the file, and i selected plain text, the text appeared with extra unprintable characters etc... so i opened as unicode and it worked fine... i'm thinking that the encoding of the file is what's causing the abnormal behavior. i'm going to open it as unicode, and resave as plain text, then run the script on it, and i expect to see correct results.well that didn't work out as expected...the new file created still says 27043 in notepad, but the same script now returns 18,854 for the first message box, with the same 0,0 for the second. sorry to say that i dont' have an explanation or a workaround at all on this one... hopefully the extra data will help someone else give you a better answer... Link to comment Share on other sites More sharing options...
Guillermo Posted October 20, 2005 Author Share Posted October 20, 2005 Actually, I think the problem does lie with the encoding. The actual number of lines, according to Excel and SciTE is 18854. I opened the original .csv file in Excel, saved it as Tab Delimited and then ran my script again. This time it counted 18854. I thought .csv files were plain text files just like .txt... Link to comment Share on other sites More sharing options...
Valuater Posted October 20, 2005 Share Posted October 20, 2005 (edited) Rather than use the file count lines through the file open ( not used in help ).... maybe try this??? FileClose($bf) $blah = _FileCountLines("c:\prueba.txt") MsgBox(0,"countline output",$blah & @crlf & @error) just an idea 8) Edited October 20, 2005 by Valuater Link to comment Share on other sites More sharing options...
seandisanti Posted October 20, 2005 Share Posted October 20, 2005 Actually, I think the problem does lie with the encoding.The actual number of lines, according to Excel and SciTE is 18854.I opened the original .csv file in Excel, saved it as Tab Delimited and then ran my script again. This time it counted 18854.I thought .csv files were plain text files just like .txt...well technically they are. i'm not sure why notepad is returning 27043 even after removing the encoding. my best guess is that there may be extra information that excel understands, and that autoit ignores after removing the encoding. Link to comment Share on other sites More sharing options...
Somerset Posted October 20, 2005 Share Posted October 20, 2005 it seems to me that it for some reason is returning the file size, or damn close to it.... Link to comment Share on other sites More sharing options...
Somerset Posted October 20, 2005 Share Posted October 20, 2005 it seems to me that it for some reason is returning the file size, or damn close to it.... well i just did the same with a binary file, and it returned the file size in negative numbers. so i have to guess the file you are trying to get counted has some sorta ascii extended charaters in it.... 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