用于创建可处理数百万行的 XLSX 文档的 Python(或 C)库

发布于 2024-11-16 10:21:28 字数 1539 浏览 8 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一杯敬自由 2024-11-23 10:21:28

你尝试过ElementTree吗?如果使用太多内存,请使用 SAX 并一次只处理一行。 XML 解析 - ElementTree 与 SAX 和 DOM

have you tried ElementTree? if that uses too much memory, use SAX and just process a row at a time. XML parsing - ElementTree vs SAX and DOM

撩心不撩汉 2024-11-23 10:21:28

XLSX 格式由许多已压缩的 XML 文件组成。如果输出的格式不会改变,那么使用现有文件作为模板并根据需要简单地向其中添加行将是微不足道的。不幸的是 ZipFile.writestr 没有不允许您分段写入文件,因此您必须将整个 XML 写入临时文件,然后使用 ZipFile.write 将其放入 zip 中。

The XLSX format consists of a number of XML files that have been zipped. If the format of the output will not be changing, it would be trivial to use an existing file as a template and simply add rows to it as necessary. Unfortunately ZipFile.writestr doesn't allow you to write the file in pieces, so you'll have to write the entire XML to a temporary file then place that into the zip with ZipFile.write.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文