开发者

Using .bat - create a second .csv from specific first column data in first .csv

I have a large .csv file and I need a batch process to create a new file with only certain lines 开发者_开发知识库that have unique identifier in the first column.

CSV looks like this. Need to create a new .csv with only the 554,134,and 6852 records.

554,Apple,car,tommy 554,cherry,bike,tom 554,banna,skateboard,tomisina

844,Apple,car,tommy 844,cherry,bike,tom 844,banna,skateboard,tomisina

134,Apple,car,tommy 134,cherry,bike,tom 134,banna,skateboard,tomisina

6852,Apple,car,tommy 6852,cherry,bike,tom 6852,banna,skateboard,tomisina

78,Apple,car,tommy 78,cherry,bike,tom 78,banna,skateboard,tomisina


I can't figure out why this was never answered before?! The answer is quite simple:

findstr /b /c:"554," /c:"134," /c:"6852," "input.csv" >"output.csv"

If you have a long list of IDs to search, prepare a file with one search string per line like so:

554,
134,
6852,

Then change the command to use the search strings in the file:

findstr /b /g:"searchStrings.txt" "input.csv" >"output.csv"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜