Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
问题描述
我有两个 3GB 的文本文件,每个文件大约有 8000 万行.并且它们共享 99.9% 的相同行(文件 A 有 60,000 个唯一行,文件 B 有 80,000 个唯一行).
I have two 3GB text files, each file has around 80 million lines. And they share 99.9% identical lines (file A has 60,000 unique lines, file B has 80,000 unique lines).
如何在两个文件中快速找到这些独特的行?是否有任何现成的命令行工具可以做到这一点?我正在使用 Python,但我想找到一种有效的 Pythonic 方法来加载文件并进行比较是不太可能的.
How can I quickly find those unique lines in two files? Is there any ready-to-use command line tools for this? I'm using Python but I guess it's less possible to find a efficient Pythonic method to load the files and compare.
欢迎提出任何建议.
推荐答案
如果顺序很重要,请尝试 comm
实用程序.如果顺序无关紧要,sort file1 file2 |uniq -u
.
If order matters, try the comm
utility. If order doesn't matter, sort file1 file2 | uniq -u
.
这篇关于快速查找两个大文本文件之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:快速查找两个大文本文件之间的差异


基础教程推荐
- 包装空间模型 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01