Python: CSV write by column rather than row

后端 未结 7 974
春和景丽
春和景丽 2020-12-01 03:46

I have a python script that generates a bunch of data in a while loop. I need to write this data to a CSV file, so it writes by column rather than row.

For example in

7条回答
  •  醉话见心
    2020-12-01 04:11

    As an alternate streaming approach:

    • dump each col into a file
    • use python or unix paste command to rejoin on tab, csv, whatever.

    Both steps should handle steaming just fine.

    Pitfalls:

    • if you have 1000s of columns, you might run into the unix file handle limit!

提交回复
热议问题