在python中处理大型XLSX文件 [英] Processing large XLSX file in python

查看:63
本文介绍了在python中处理大型XLSX文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的 xlsx Excel 文件(56mb,550k 行),我试图从中读取前 10 行.我尝试使用 xlrdopenpyxlpyexcel-xlsx,但它们总是需要超过 35 分钟,因为它将整个文件加载到内存中.

I have a large xlsx Excel file (56mb, 550k rows) from which I tried to read the first 10 rows. I tried using xlrd, openpyxl, and pyexcel-xlsx, but they always take more than 35 mins because it loads the whole file in memory.

我解压 Excel 文件,发现包含我需要的数据的 xml 已解压 800mb.

I unzipped the Excel file and found out that the xml which contains the data I need is 800mb unzipped.

在 Excel 中加载同一个文件需要 30 秒.我想知道为什么在 Python 中需要这么多时间?

When you load the same file in Excel it takes 30 seconds. I'm wondering why it takes that much time in Python?

推荐答案

使用 openpyxl 的 read-only 模式 来做到这一点.

Use openpyxl's read-only mode to do this.

您将能够立即使用相关工作表.

You'll be able to work with the relevant worksheet instantly.

这篇关于在python中处理大型XLSX文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆