Questions tagged [xlrd]

xlrd is a python library to extract data from Microsoft Excel spreadsheet files

xlrd is a python library to extract data from Microsoft Excel spreadsheet files.

xlrd can extract data from Excel spreadsheets (.xls and .xlsx, versions 2.0 onwards) on any platform, is written in pure Python and is Unicode-aware.

1366 questions
286
votes
2 answers

xlrd.biffh.XLRDError: Excel xlsx file; not supported

I am trying to read a macro-enabled Excel worksheet using pandas.read_excel with the xlrd library. It's running fine in local, but when I try to push the same into PCF, I am getting this error: 2020-12-11T21:09:53.441+05:30 [APP/PROC/WEB/0] [ERR]…
Vignesh K
  • 2,879
  • 2
  • 6
  • 6
278
votes
12 answers

Pandas: Looking up the list of sheets in an excel file

The new version of Pandas uses the following interface to load Excel files: read_excel('path_to_file.xls', 'Sheet1', index_col=None, na_values=['NA']) but what if I don't know the sheets that are available? For example, I am working with excel…
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
251
votes
13 answers

Create a .csv file with values from a Python list

I am trying to create a .csv file with the values from a Python list. When I print the values in the list they are all unicode (?), i.e. they look something like this [u'value 1', u'value 2', ...] If I iterate through the values in the list i.e.…
Fortilan
  • 2,645
  • 2
  • 17
  • 10
96
votes
8 answers

Reading Excel File using Python, how do I get the values of a specific column with indicated column name?

I've an Excel File: Arm_id DSPName DSPCode HubCode PinCode PPTL 1 JaVAS 01 AGR 282001 1,2 2 JaVAS 01 AGR 282002 …
Praful Bagai
  • 16,684
  • 50
  • 136
  • 267
66
votes
5 answers

writing to existing workbook using xlwt

I am unable to find examples where xlwt is used to write into existing files. I have a existing xls file that I need to write to. When I use xlrd to read the file, I cant seem to figure out how to transform the "Book" type returned into a…
Raj N
  • 955
  • 1
  • 9
  • 10
64
votes
2 answers

GroupBy results to dictionary of lists

I have an excel sheet that looks like so: Column1 Column2 Column3 0 23 1 1 5 2 1 2 3 1 19 5 2 56 1 2 22 2 3 2 4 3 14 5 4 59 1 5 44 1 5 …
SuperDougDougy
  • 701
  • 1
  • 5
  • 10
64
votes
10 answers

How to obtain sheet names from XLS files without loading the whole file?

I'm currently using pandas to read an Excel file and present its sheet names to the user, so he can select which sheet he would like to use. The problem is that the files are really big (70 columns x 65k rows), taking up to 14s to load on a notebook…
pcarvalho
  • 685
  • 1
  • 5
  • 7
57
votes
2 answers

Preserving styles using python's xlrd,xlwt, and xlutils.copy

I'm using xlrd, xlutils.copy, and xlwt to open up a template file, copy it, fill it with new values, and save it. However, there doesn't seem to be any easy way to preserve the formatting of the cells; it always gets blown away and set to blank. Is…
YGA
  • 9,546
  • 15
  • 47
  • 50
54
votes
24 answers

python xlrd unsupported format, or corrupt file.

My code: import xlrd wb = xlrd.open_workbook("Z:\\Data\\Locates\\3.8 locates.xls") sh = wb.sheet_by_index(0) print sh.cell(0,0).value The error: Traceback (most recent call last): File "Z:\Wilson\tradedStockStatus.py", line 18, in wb =…
wDroter
  • 1,209
  • 4
  • 17
  • 25
41
votes
3 answers

error: could not create '/Library/Python/2.7/site-packages/xlrd': Permission denied

I'm trying to install xlrd on mac 10.8.4 to be able to read excel files through python. I have followed the instructions on http://www.simplistix.co.uk/presentations/python-excel.pdf I did this: unzipped the folder to desktop in terminal, cd to the…
Sammy
  • 669
  • 2
  • 8
  • 13
37
votes
4 answers

Identifying Excel Sheet cell color code using XLRD package

I am writing a python script to read data from an excel sheet using xlrd. Few of the cells of the the work sheet are highlighted with different color and I want to identify the color code of the cell. Is there any way to do that ? An example would…
Kinjal
  • 718
  • 2
  • 11
  • 21
34
votes
2 answers

Edit existing excel workbooks and sheets with xlrd and xlwt

In the documentation for xlrd and xlwt I have learned the following: How to read from existing work-books/sheets: from xlrd import open_workbook wb = open_workbook("ex.xls") s = wb.sheet_by_index(0) print s.cell(0,0).value #Prints contents of cell…
Jack Pettersson
  • 1,606
  • 4
  • 17
  • 28
33
votes
4 answers

how to open xlsx file with python 3

I have an xlsx file with 1 sheet. I am trying to open it using python 3 (xlrd lib), but I get an empty file! I use this code: file_errors_location = "C:\\Users\\atheelm\\Documents\\python excel mission\\errors1.xlsx" workbook_errors =…
Atheel Massalha
  • 483
  • 1
  • 4
  • 10
32
votes
6 answers

Python xlwt - accessing existing cell content, auto-adjust column width

I am trying to create an Excel workbook where I can auto-set, or auto-adjust the widths of the columns before saving the workbook. I have been reading the Python-Excel tutorial in hopes of finding some functions in xlwt that emulate xlrd ones (such…
nooblar
  • 399
  • 1
  • 5
  • 12
31
votes
5 answers

Converting a Python Float to a String without losing precision

I am maintaining a Python script that uses xlrd to retrieve values from Excel spreadsheets, and then do various things with them. Some of the cells in the spreadsheet are high-precision numbers, and they must remain as such. When retrieving the…
jloubert
  • 974
  • 2
  • 8
  • 12
1
2 3
91 92