xlrd

How to get line number in excel sheet using python?

眉间皱痕 提交于 2019-11-30 18:56:17
I have an Excel sheet like this: A B C D E F G 1 0 0 0 2 0 0 3 0 4 5 0 0 0 0 0 0 0 6 0 0 0 And every '0' represents some data values, I am reading the values and comparing them with my original data, when the data match fails it returns a message. What I want is to return the line number of excel sheet as well as the column number or particularly the CELL location. Please help me doing this! arulmr Try this: import xlrd workbook = xlrd.open_workbook('book.xls') for sheet in workbook.sheets(): for row in range(sheet.nrows): for column in range(sheet.ncols): print "row::::: ", row print "column:

Python xlrd read as string

匆匆过客 提交于 2019-11-30 18:47:18
I'm having difficulties in reading a particular cell value from Excel in xlrd. Whatever value I'm reading (date value) is getting converted to a number. I know there are solutions to convert it into a python date format, but can I read directly the string value in xlrd? John Machin xlrd does NOT convert dates to float. Excel stores dates as floats. Quoting from the xlrd documentation (scroll down a page): Dates in Excel spreadsheets In reality, there are no such things. What you have are floating point numbers and pious hope. There are several problems with Excel dates: (1) Dates are not

Python xlrd read as string

本秂侑毒 提交于 2019-11-30 16:53:47
问题 I'm having difficulties in reading a particular cell value from Excel in xlrd. Whatever value I'm reading (date value) is getting converted to a number. I know there are solutions to convert it into a python date format, but can I read directly the string value in xlrd? 回答1: xlrd does NOT convert dates to float. Excel stores dates as floats. Quoting from the xlrd documentation (scroll down a page): Dates in Excel spreadsheets In reality, there are no such things. What you have are floating

How can I edit Excel Workbooks using XLRD or openpyxl while preserving charts?

我与影子孤独终老i 提交于 2019-11-30 15:57:46
问题 I have a workbook that has some sheets in it. One of the sheets has charts in it. I need to use xlrd or openpyxl to edit another sheet, but, whenever I save the workbook, the charts are gone. Any workaround to this? Is there another python package that preserves charts and formatting? 回答1: This is currently not possible with either but I hope to have it in openpyxl 2.x. Patches / pull requests always welcome! ;-) 来源: https://stackoverflow.com/questions/19323049/how-can-i-edit-excel-workbooks

How can I edit Excel Workbooks using XLRD or openpyxl while preserving charts?

大城市里の小女人 提交于 2019-11-30 15:39:19
I have a workbook that has some sheets in it. One of the sheets has charts in it. I need to use xlrd or openpyxl to edit another sheet, but, whenever I save the workbook, the charts are gone. Any workaround to this? Is there another python package that preserves charts and formatting? This is currently not possible with either but I hope to have it in openpyxl 2.x. Patches / pull requests always welcome! ;-) 来源: https://stackoverflow.com/questions/19323049/how-can-i-edit-excel-workbooks-using-xlrd-or-openpyxl-while-preserving-charts

Opening and reading an excel .xlsx file in python

[亡魂溺海] 提交于 2019-11-30 15:03:54
I'm trying to open an excel .xlsx file with python but am unable to find a way to do it, I've tried using pandas but it's wanting to use a library called NumPy I've tried to install numpy but it still can't find numpy. I've also tried using the xlrd library but I get the following traceback: Traceback (most recent call last): File "C:\test.py", line 3, in <module> book = open_workbook('test.xlsx') File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 370, in open_workbook biff_version = bk.getbof(XL_WORKBOOK_GLOBALS) File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 1323, in

xlrd import issue with Python 2.7

孤者浪人 提交于 2019-11-30 12:13:12
I have an assignment to read excel data in Python. I have Python 2.7 installed. I tried installing xlrd0.8.0 with the following commands in Windows. C:\Python27\xlrd-0.8.0>python setup.py build running build running build_py creating build creating build\lib creating build\lib\xlrd copying xlrd\biffh.py -> build\lib\xlrd .... C:\Python27\xlrd-0.8.0>python setup.py install running install running build running build_py running build_scripts running install_lib running install_scripts running install_egg_info Writing C:\Python27\Lib\site-packages\xlrd-0.8.0-py2.7.egg-info I don't get any error

How to get excel sheet name in Python using xlrd

淺唱寂寞╮ 提交于 2019-11-30 05:24:49
问题 Please see the code below. def getSheetName(file_name): pointSheetObj = [] import xlrd as xl TeamPointWorkbook = xl.open_workbook(file_name) pointSheets = TeamPointWorkbook.sheet_names() for i in pointSheets: pointSheetObj.append(TeamPointWorkbook.sheet_by_name(i)) I need to get the name of the excel sheet name from the list pointSheetObj by iterating it. 回答1: I have modified the code I gave as a question and have got what I needed actually, def getSheetName(file_name): pointSheetObj = []

Python中xlrd模块解析

别来无恙 提交于 2019-11-30 02:54:59
Python中xlrd模块解析 xlrd 导入模块 import xlrd 2、打开指定的excel文件,返回一个data对象 data = xlrd.open_workbook(file) #打开excel表,返回data对象 3、通过data对象可以得到各个sheet对象(一个excel文件可以有多个sheet,每个sheet就是一张表格) Sheet1 = data.sheet_by_index(0) #通过索引顺序获取 sheet_by_index(0)为第一个sheet 同理sheet_by_index(1)为第二个sheet 获取的sheet返回的是16进制地址 # ,如:<xlrd.sheet.Sheet object at 0x000001FC8E966208> Sheet1 = data.sheet_by_name(''sheet名称'') #通过名称获取 同上返回的sheet是一个16进制地址对象 Sheet1 = data.sheets()[0] #通过索引顺序获取 同第一个差不多,效果一样 num =data.nsheets #返回sheet的数目 list = data.sheets() #返回所有sheet对象的列表 list = data.sheet_names() #返回所有sheet对象名字的列表 此方式返回的对象是sheet的展示表名 4

Is there a way to close a workbook using xlrd

早过忘川 提交于 2019-11-30 00:23:49
问题 I am using the function open_workbook() to open an excel file. But I cannot find any function to close the file later in the xlrd module. Is there a way to close the xls file using xlrd? Or is not required at all? 回答1: Digging into the mailing list archive, it seems that the file object is closed directly by the constructor, so you don't need to close it explicitly. 回答2: The open_workbook calls the release_resources ( which closes the mmaped file ) before returning. 来源: https://stackoverflow