问题
I have a file that has
Class,section,name
Math,02,Scott
What I need is a .csv that copies a column so it looks like below
Class,section,name,class
Math,02,Scott,Math
I am looking to do this using batch file commands. Any suggestions? I know how to do basic copy commands, and tried downloading python but was having trouble getting it to work
回答1:
@ECHO OFF
SETLOCAL
(
FOR /f "tokens=1-3delims=," %%a IN (q22334682.txt) DO (
ECHO(%%a,%%b,%%c,%%a
)
)>new.csv
GOTO :EOF
-Assuming that the case of the class header on the generated column in the file should match that in column 1.
I used a file named q22334682.txt for my testing, putting the result in new.csv.
来源:https://stackoverflow.com/questions/22334682/copy-a-column-in-a-csv-file-to-another-using-batch