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

后端 未结 7 2086
一个人的身影
一个人的身影 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:29

    Sed one-liner:

    sed -e '/^1,/wFile1' -e '/^2,/wFile2' -e '/^3,/wFile3' ... OriginalFile 
    

    The only down-side is that you need to put in n -e statements (represented by the ellipsis, which shouldn't appear in the final version). So this one-liner might be a pretty long line.

    The upsides, though, are that it only makes one pass through the file, no sorting is assumed, and no python is needed. Plus, it's a one-freaking-liner!

提交回复
热议问题