Java中forecho循环,批处理脚本:更快的ECHO输出到FOR循环中的csv文件?

I wrote a script that replaces the semicolon delimiter in a text file to commas, but it also puts quotes around the text of the 9th column since the 9th column contains commas. When I output to the new text file it process very slow, takes maybe 4-5 minutes, the text file that it is reading from is 50MB. Is there faster way or more efficient way to do this? Here is my FOR loop:

FOR /f "usebackq tokens=1-9* delims=;" %%a IN ("%FILENAME%") DO (

SET C10=%%j

ECHO(%%a,%%b,%%c,%%d,%%e,%%f,%%g,%%h,"%%i",!C10:;=,! >> "%MYPATH%\Filename %MMDDYYYY%.csv")

or should I just learn python.....

Thank you.

解决方案

One thing that will make the script run "faster" is to avoid opening and closing the output file for each write operation

>> "%MYPATH%\Filename %MMDDYYYY%.csv" (

FOR /f "usebackq tokens=1-9* delims=;" %%a IN ("%FILENAME%") DO (

SET C10=%%j

ECHO(%%a,%%b,%%c,%%d,%%e,%%f,%%g,%%h,"%%i",!C10:;=,!

)

)

Instead of redirecting each line, redirect the full for command.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值