作者os653 ()
看板Python
标题[问题] openpyxl 吃太多记忆体
时间Thu Apr 6 06:57:04 2017
问题:用 openpyxl 写入约 100 万列的资料,会吃掉好几 G 的记忆体
依据
https://openpyxl.readthedocs.io/en/latest/optimized.html 的说明
Write-only mode
It is able to export unlimited amount of data
(even more than Excel can handle actually),
while keeping memory usage under 10Mb.
尝试根据上列网址把程式改成 Write-only mode 後,
虽然感觉吃记忆体的程度大幅下降
但大概是从吃 8G 记忆体变成吃 2G 记忆体,
问题依旧存在,
离说明中的可以只吃 10Mb 记忆体有很大差距,
请问有解吗?
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 36.233.139.250
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1491433028.A.EFA.html
1F:→ KSJ: 有你的CODE可看吗? 04/06 12:28
基本上跟官网的一样,测试 code 如下:
from openpyxl import Workbook
wb = Workbook(write_only=True)
ws = wb.create_sheet()
for irow in range(100000):
ws.append(['%d' % i for i in range(200)])
开工作管理员就会看到记忆体使用量不断飙高
openpyxl version 2.4.4
※ 编辑: os653 (36.233.139.250), 04/06/2017 19:41:51