用python解析excel文件 [英] parsing excel documents with python

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

问题描述

我想将Excel文档解析成Python中的列表。
有没有一个python库对这个动作有帮助?
那个库里有什么功能?

解决方案

你最好打算解析Excel文件是 xlrd 图书馆。 python-excel.org 网站包含 xlrd 和相关的python excel库,包括一个 pdf文档,它有一些使用xlrd的很好的例子。当然,在StackOverflow上也有许多可能有用的相关的xlrd问题



一个关于xlrd库的警告是,它只适用于 xls (Excel 2003和更低版本的excel)文件格式,而不是最近的 xlsx 文件格式。有一个较新的图书馆 openpyxl 处理 xlsx ,但我从来没有使用过。



更新
根据John的评论, xlrd 库现在支持 xls xlsx 文件格式。



希望有所帮助。


I want to parse excel document to lists in Python. Is there a python library which is helpful for this action? And what functions are relevant in that library?

解决方案

You're best bet for parsing Excel files would be the xlrd library. The python-excel.org site has links and examples for xlrd and related python excel libraries, including a pdf document that has some good examples of using xlrd. Of course, there are also lots of related xlrd questions on StackOverflow that might be of use.

One caveat with the xlrd library is that it will only work with xls (Excel 2003 and earlier versions of excel) file formats and not the more recent xlsx file format. There is a newer library openpyxl for dealing with the xlsx, but I have never used it.

UPDATE: As per John's comment, the xlrd library now supports both xls and xlsx file formats.

Hope that helps.

这篇关于用python解析excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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