批处理文件以比较两个csv文件中的差异 [英] Batch file to compare the differences in two csv files
本文介绍了批处理文件以比较两个csv文件中的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Windows 7. 我有两个csv文件file1.csv和file2.csv
I use windows 7. I have two csv files file1.csv and file2.csv
file1.csv
file1.csv
emp_id;salary
1;1000
2;2000
3;3000
file.csv
emp_id;salary
1;1000
2;2000
3;3000
4;4000
5;5000
我很困惑如何编写批处理文件. 批处理文件应输出,应该是显示更改的csv文件.
I'm confused how to write a batch file. The batch file should output the should be a csv file showing the changes.
示例输出:
emp_id;salary
4;4000
5;5000
推荐答案
您可以使用findstr
查找差异,并使用/v
参数显示差异.像这样:
You can use findstr
to look for differences, and the /v
parameter to display differences. Like so:
findstr /v /g:"file1.csv" "file2.csv"
也:
for /f "delims=" %%a in (file1.csv) do (
findstr "^%%a$" "file2.csv" >nul ||echo %%a
)
并使用fc
命令:
fc "file1.csv" "file2.csv"
对于fc
,我确定您可以使用if not errorlevel 1 echo No difference
For fc
im sure you can use an if not errorlevel 1 echo No difference
这篇关于批处理文件以比较两个csv文件中的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文