2008-02-19
python读取其它格式文件的模块
python读取excel文件数据的方法。一种方法是先把xls文件转换为csv格式文件,然后用csv模块(自带)解释,一种是用xlrd模块(需下载安装)来直接读取文件信息。该模块的网址为:
http://www.lexicon.net/sjmachin/xlrd.htm
例子为:
压缩包中的DOC目录带有使用文档及例程。
python解释CSV格式的文件,标准python自有csv模块,在Python Library Reference的第9节有介绍,或者从以下网址可得到一些例子:
http://www.object-craft.com.au/projects/csv/
python读取PDF文件的模块pyPdf:
http://pybrary.net/pyPdf/
带软件包及介绍,例子。
http://www.lexicon.net/sjmachin/xlrd.htm
例子为:
Quick start:
import xlrd
book = xlrd.open_workbook("myfile.xls")
print "The number of worksheets is", book.nsheets
print "Worksheet name(s):", book.sheet_names()
sh = book.sheet_by_index(0)
print sh.name, sh.nrows, sh.ncols
print "Cell D30 is", sh.cell_value(rowx=29, colx=3)
for rx in range(sh.nrows):
print sh.row(rx)
# Refer to docs for more details.
# Feedback on API is welcomed.
压缩包中的DOC目录带有使用文档及例程。
python解释CSV格式的文件,标准python自有csv模块,在Python Library Reference的第9节有介绍,或者从以下网址可得到一些例子:
http://www.object-craft.com.au/projects/csv/
python读取PDF文件的模块pyPdf:
http://pybrary.net/pyPdf/
带软件包及介绍,例子。
发表评论
- 浏览: 14353 次
- 性别:


- 详细资料
搜索本博客
最新评论
-
py2exe越来越爽了
[size=large][size=medium]大家好,python新手。现遇 ...
-- by davidsun2008 -
DLang策略模式
我会尝试着把模式详尽剖析。不过能力有限,望大家多提宝贵意见。
-- by jinheking -
DLang策略模式
不错的理念,赞一个。 能详尽剖析就更好了
-- by DavidL -
DLang策略模式
可以像很多D项目一样,自己写一个all.d,在这里面import上所有的modu ...
-- by shawind -
DLang策略模式
引用module 怎么让我的程序做的像import std.stdio; 而不用 ...
-- by jinheking






评论排行榜