How can I split a large file csv file (7GB) in Python

前端 未结 5 1711
我在风中等你
我在风中等你 2020-12-23 22:34

I have a 7GB csv file which I\'d like to split into smaller chunks, so it is readable and faster for analysis in Python on a notebook. I would like to grab a sm

5条回答
  •  既然无缘
    2020-12-23 22:57

    I had to do a similar task, and used the pandas package:

    for i,chunk in enumerate(pd.read_csv('bigfile.csv', chunksize=500000)):
        chunk.to_csv('chunk{}.csv'.format(i), index=False)
    

提交回复
热议问题