read csv file through windows batch file and create txt file

后端 未结 1 1880
无人及你
无人及你 2021-01-07 02:47

I have an excel file with 5 values each in a line. now, i want to read the .csv file through batch file and create text file with the contents in the file. Example, if i hav

1条回答
  •  时光说笑
    2021-01-07 03:10

    there are a lot of similar questions answered in SOF. Few of them to refer are :

    Reading from a csv file and extracting certain data columns based on first column value

    Help in writing a batch script to parse CSV file and output a text file

    How do you loop in a Windows batch file?

    Simplest answer is to loop thru your file using:

    FOR %A IN (list) DO command [ parameters ]
    

    Example:

    Sample CSV:

    0,1,2,4
    1,1,2,3
    2,2,4,6
    3,3,6,9
    

    bat file content:

    for /f "usebackq tokens=1-4 delims=," %%a in ("sample1.csv") do (
          echo %%a %%b %%c %%d )
    

    here tokens=1-4 meaning that we wish to read 4 column data for each line

    0 讨论(0)
提交回复
热议问题