Python: Fast and efficient way of writing large text file

前端 未结 3 1518
心在旅途
心在旅途 2020-12-11 06:33

I have a speed/efficiency related question about python:

I need to write a large number of very large R dataframe-ish files, about 0.5-2 GB sizes. This is basically

3条回答
  •  一整个雨季
    2020-12-11 07:21

    Unless you are running into a performance issue, you can probably write to the file line by line. Python internally uses buffering and will likely give you a nice compromise between performance and memory efficiency.

    Python buffering is different from OS buffering and you can specify how you want things buffered by setting the buffering argument to open.

提交回复
热议问题