使用批处理将 .csv 文件中的列复制到另一个 [英] copy a column in a .csv file to another using batch

查看:34
本文介绍了使用批处理将 .csv 文件中的列复制到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

解决方案

@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.

这篇关于使用批处理将 .csv 文件中的列复制到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆