Wednesday, 6 March 2013

Python: Read excel files with library xlrd

Python is able to read/write excel files with the help fo the xlrd library.

Installing xlrd
  1. Download it from here and extract it
  2. Start terminal and go to the xlrd extracted directory
  3. Type in 'setup.py install' and press enter to start the installation
Sample code

import xlrd

book = xlrd.open_workbook('keyword.xlsx');

print book.nsheets
print book.sheet_names()

sh = book.sheet_by_index(0)
print sh.name, sh.nrows, sh.ncols



Source:
http://stackoverflow.com/questions/3504604/recommend-a-python-library-to-read-excel-xls-files

No comments:

Post a Comment