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 have Apple, Mango in csv file (in one column), then the batch file should read this .csv file and should create a text file like " Apple is a fruit" and in next line " Mango is a fruit". Can anyone share the code please.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With