|
Answer» How to get the total NUMBER of row records from a csv file by a BATCH file METHOD?
For example, the total number of rows in a csv file is 320 and i WANT to get the number and PUT it into a variable.
thanks!Assuming that there are no blank rows, try
find /c /v "" MyFile.csv | sort /R >findcount.txt
This will output a line like this ---------- MYFILE.CSV: 190 Which you can then pull into a variable and parse with Set /P MyCount= The sort is necessary as the output from the FIND has a leading blank line, which messes up the set statement.
The find statement searches for all lines that do not contain a blank string (the /v means not contains) and the /c means just provide the count of returned rows.
Hope this sorts you out Grahamyeah! it helps a lot! thanks!
|