Pickle alternatives

后端 未结 8 2148
南旧
南旧 2021-02-05 04:16

I am trying to serialize a large (~10**6 rows, each with ~20 values) list, to be used later by myself (so pickle\'s lack of safety isn\'t a concern).

Each row of the lis

8条回答
  •  孤街浪徒
    2021-02-05 04:26

    I usually serialize to plain text (*.csv) because I found it to be fastest. The csv module works quite well. See http://docs.python.org/library/csv.html

    If you have to deal with unicode for your strings, check out the UnicodeReader and UnicodeWriter examples at the end.

    If you serialize for your own future use, I guess it would suffice to know that you have the same data type per csv column (e.g., string are always on column 2).

提交回复
热议问题