copy a column in a .csv file to another using batch

南楼画角 提交于 2019-12-20 06:27:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!