划分脚本以删除rown,其中列值在“ in”中。和“ br&quot”
我有一个CSV文件,该文件具有35列,在第19列中,我得到了这些国家价值,例如IN,BR,US等。我需要删除第19列中国家价值的行和Br。
我尝试了以下问题,但有很多问题,因为我只能使用令牌直至26,也无法在BR中使用。
@echo off &setlocal
set /p "header="<"old.csv"
>"your new.csv" echo.%header%
for /f "usebackq skip=1 delims=, tokens=1-26*" %%a in ("old.csv") do (
if not "%%t" == "BR"
(
>>"your new.csv" echo.%%a,%%b,%%c,%%d.....,%%Z
)
)
I Have a csv file which has 35 columns and in 19th column i get these country values like IN, BR, US etc. I need to remove the rows where the country value in 19th column is IN and BR.
I tried the following but has many issues as i can use tokens upto 26 only and also not being able to use both IN and BR.
@echo off &setlocal
set /p "header="<"old.csv"
>"your new.csv" echo.%header%
for /f "usebackq skip=1 delims=, tokens=1-26*" %%a in ("old.csv") do (
if not "%%t" == "BR"
(
>>"your new.csv" echo.%%a,%%b,%%c,%%d.....,%%Z
)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该有效:
从
for /?< /code>帮助屏幕:
换句话说,在以前的代码中,
%% T
令牌接收所有列在第19个...之后...This should work:
From the
FOR /?
help screen:In other words, in previous code the
%%t
token receive all the columns after the 19th one...[未经测试]
...但请记住评论中的要点。
[untested]
...but keep in mind the points raisd in the comments.