我想将一个长text.csv
的文本文件(例如2 x 400,000)拆分为80个较小的文件(2 x 6000)。理想情况下,我想将每个较小的文件作为text1.csv,text2.csv等写入磁盘。最有效的方法是什么?
col 1 col2
0 text text
1 text text
2 text text
...
399999 text text
400000 text text
较小的文件如下所示:
col 1 col2
0 text text
1 text text
2 text text
...
4999 text text
5000 text text
col 1 col2
5001 text text
5002 text text
5003 text text
...
9999 text text
10000 text text
etc.
答案 0 :(得分:0)
我自己不会为此写任何东西,而是在shell上使用split命令-或可能将其作为python中的外部程序调用。参见:
How to split a large text file into smaller files with equal number of lines?