且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何有效地在python中编写csv?

更新时间:2023-11-18 22:08:34

CSV 是CSV,没有太多可以做的事。您可以直接 gzip ,如果您真的想要

CSV is CSV and there is not much you can do about it. You can simply gzip it, if you really want to stick with CSV, or you can use some custom format that better fits your needs.

例如,您可以使用字典并导出到 JSON 格式,或者创建一个专用对象来处理您的数据和 pickle

For example you can use a dictionary and export to JSON format, or create a dedicated object that handles your data and pickle it.

当我使用TF-IDF时,我使用 sqlite (通过 sqlalchemy )存储文档信息,将TF数据作为JSON格式的字典。从那时起,我创建了IDF统计信息,之后使用 numpy

When I worked with TF-IDF, I used sqlite (via sqlalchemy) to store documents information, with TF data as dictionary in JSON format. From that I created IDF stats, and later did rest of TFIDF, using numpy