Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
filename = "C:\Temp\Example.txt" String = @LF ; number of lines / records fs = FileSize(filename) buffer = binaryalloc( fs ) BinaryRead(buffer,filename ) count = BinaryStrCnt( buffer, 0, fs-1, String) ;Check If the last line ends with a "lf" if so disregard. if binarypeekstr(buffer, fs-1, 1)!=String then count = count-1 BinaryFree( buffer ) Message( "Number of lines /records", count )
Another way might be:
filename = "C:\Test\Example.txt" file = Fileget(filename) file = strreplace(file,@crlf,@tab) ; assumes no tabs in the file already records = itemcount(file,@tab) if itemextract(-1,file,@tab) == "" then records = records - 1 ; last line followed by "crlf" Message( "Number of lines /records", records)
Another way might be:
filename = "c:\temp\test.csv" array = ArrayFileGetCsv(filename, 0, ",", 0, 0) rowcount = ArrInfo(array,1) colcount = ArrInfo(array,2) Message(StrCat("Number of Rows in the file ",rowcount), StrCat("Number of Columns in the file ",colcount))
Article ID: W16398
File Created: 2005:02:18:12:20:22
Last Updated: 2005:02:18:12:20:22