I have this .bat file that I use to open .csv files, which counts the lines in them and uses Excel to open if under a million records and a separate program to open if more than a million records. The issue I'm running into is that if the file has more than ~ five million records it seems like the .bat takes a long time to count them before opening in the second program (sometimes ~10 seconds) and that kind of defeats the purpose of having this script to intelligently choose which program to use. The code I'm currently using is:
set LINE_COUNT=0
for /f %%a in ('type "%CSV_FILE%" ^| find /c /v ""') do set LINE_COUNT=%%a
If there's a faster way to do this I'm all ears.
I tried using a filesize threshold, first but sometimes the data structure has a far greater number of fields than records, so I'll have a large file size with less than a million records and don't want those opening in the second program.