openpyxl writing large file memory issue

北城以北 提交于 2020-03-01 05:20:06

问题


I'm trying to create a 75col by 650k rows document using openpyxl write only workbook, which is said to bear near constant memory footprint, but after a while I get 17.2GB memory usage in activity monitor, here's the code I'm using, am I doing something wrong?

def testOPENPYXL():
    wb = openpyxl.Workbook(write_only=True)
    ws = wb.create_sheet()
    for irow in range(650000):
        ws.append(['%d' % i for i in range(75)])
    path = os.path.expanduser("~/Desktop/test/test.xlsx")
    wb.save(path)

回答1:


The simple solution is to install lxml we have a shim in openpyxl that mimics lxml's streaming writer but it isn't as memory efficient.



来源:https://stackoverflow.com/questions/41043672/openpyxl-writing-large-file-memory-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!