xlrd

Python: Convert xlrd sheet to numpy matrix (ndarray)

Python: Convert xlrd sheet to numpy matrix (ndarray) Question: What is the conversion syntax to convert a successfully loaded xlrd excel sheet to a numpy matrix (that represents that sheet)? Right now I’m trying to take each row of the spreadsheet and add it to the numpy matrix. I can’t figure out the syntax for …

Total answers: 3

Edit existing excel workbooks and sheets with xlrd and xlwt

Edit existing excel workbooks and sheets with xlrd and xlwt Question: 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 at location a1 in the first sheet in the document …

Total answers: 2

XLRD/Python: Reading Excel file into dict with for-loops

XLRD/Python: Reading Excel file into dict with for-loops Question: I’m looking to read in an Excel workbook with 15 fields and about 2000 rows, and convert each row to a dictionary in Python. I then want to append each dictionary to a list. I’d like each field in the top row of the workbook to …

Total answers: 5

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

error: could not create '/Library/Python/2.7/site-packages/xlrd': Permission denied Question: 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 unzipped folder $ python setup.py install This is what I …

Total answers: 3

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

Pandas: Looking up the list of sheets in an excel file Question: 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 files that the following sheets Data 1, Data …

Total answers: 12

Using Python, write an Excel file with columns copied from another Excel file

Using Python, write an Excel file with columns copied from another Excel file Question: I have an Excel file containing a varying number of columns, I would like to loop through certain columns (from their header row value) of that file using Python, then write (copy) those columns to another Excel file. Any examples on …

Total answers: 1

How to set NULL for IntegerField instead of setting 0?

How to set NULL for IntegerField instead of setting 0? Question: I’m uploading some data from an excel file using xlrd and turning that data into models (with mainly IntegerField values) in Django. My excel file has a bunch of missing data. Unfortunately, these missing data are converted to the value of 0 in my …

Total answers: 1

Extract columns from Excel using Python

Extract columns from Excel using Python Question: I have an Excel file with the ff: row/col structure ID English Spanish French 1 Hello Hilo Halu 2 Hi Hye Ghi 3 Bus Buzz Bas I would like to read the Excel file, extract the row and col values, and create 3 new files base on the …

Total answers: 3

Python Creating Dictionary from excel data

Python Creating Dictionary from excel data Question: I want to create a dictionary from the values, i get from excel cells, My code is below, wb = xlrd.open_workbook(‘foo.xls’) sh = wb.sheet_by_index(2) for i in range(138): cell_value_class = sh.cell(i,2).value cell_value_id = sh.cell(i,0).value and I want to create a dictionary, like below, that consists of the values …

Total answers: 10