python读取excel格式的文件
2014-03-06 18:41
741 查看
使用 xlrd 能够很方便的读取 excel 文件内容,而且这是个跨平台的库,能够在windows,linux/unix,等平台上面使用。
软件可以去这个地址http://www.lexicon.net/sjmachin/xlrd.htm下载。
http://sc.openoffice.org/excelfileformat.pdf
本文出自 “linux学习与交流” 博客,请务必保留此出处http://yangcan918.blog.51cto.com/5518117/1369418
软件可以去这个地址http://www.lexicon.net/sjmachin/xlrd.htm下载。
简单例子
importxlrd fname = "sample.xls" bk = xlrd.open_workbook(fname) shxrange = range(bk.nsheets)try: sh = bk.sheet_by_name("Sheet1")except: print"no sheet in %s named Sheet1"% fname returnNone nrows = sh.nrows ncols = sh.ncolsprint"nrows %d, ncols %d"%(nrows,ncols) cell_value = sh.cell_value(1,1)print cell_value row_list = []for i inrange(1,nrows): row_data = sh.row_values(i) row_list.append(row_data)
xlrd 模块内容
详细的xlrd模块帮助在他的主页上http://www.lexicon.net/sjmachin/xlrd.htmlexcel 文件格式
如果想彻底研究excel的话,这边有讲解excel格式的文档:http://sc.openoffice.org/excelfileformat.pdf
本文出自 “linux学习与交流” 博客,请务必保留此出处http://yangcan918.blog.51cto.com/5518117/1369418
相关文章推荐
- Python使用xlrd读取Excel格式文件的方法
- Python使用xlrd读取Excel格式文件的方法
- Python 使用 xlrd 读取 Excel格式文件
- Python 使用 xlrd 读取 Excel格式文件
- Python 使用 xlrd 读取 Excel格式文件
- Python读取Excel文件遇到的编码问题(pycharm)
- 用 java 读取excel 文件里的时间格式数据时,24时制会自动转化为12时制,解决办法
- Python读取excel文件(xlrd,xlwt)
- Python读取txt内容写入xls格式的excel中
- python 读取excel文件 - 编码是个头疼的问题
- Python读取和写入Excel文件[整]
- Win7,64位下Python读取Excel文件并绘制图表
- python读取excel,数字都是浮点型,日期格式是数字的解决办法(转)
- python读取pgm格式图片文件
- 使用python读取.txt文件并保存到Excel中
- 用python 读取和写入CSV格式的文件
- Asp.Net读取excel文件的时候 出错提示:外部表不是预期的格式 解决方案
- ABAP读取Excel文件,转成对应格式内表
- 用python读取MiniSEED格式文件
- python通过串口读取GPS NMEA格式的数据,并保存为csv文件