How to split a huge csv file based on content of first column?

后端 未结 7 2085
一个人的身影
一个人的身影 2020-12-01 17:01
  • I have a 250MB+ huge csv file to upload
  • file format is group_id, application_id, reading and data could look like


        
7条回答
  •  借酒劲吻你
    2020-12-01 17:32

    If the rows are sorted by group_id, then itertools.groupby would be useful here. Because it's an iterator, you won't have to load the whole file into memory; you can still write each file line by line. Use csv to load the file (in case you didn't already know about it).

提交回复
热议问题