xlrd

What it is good for?

Read Excel documents.

The xlrd module reads a spreadsheet into a hierarchical data structure. On top are sheets, consisting of rows which in turn consist of columns.
The corresponding Python module xlwt allows you to write Excel spreadsheets. You may also consider the newer openpyxl module.

Installed with Python by default?

no

Installed with Anaconda?

yes

How to install it?

  1. pip install xlrd

Example

  1. # Create a simple Excel file 'hamlet.xlsx' to begin with!
  2. import xlrd
  3. workbook = xlrd.open_workbook('hamlet.xlsx')
  4. sheet_names = workbook.sheet_names()
  5. sheet = workbook.sheet_by_name(sheet_names[0])
  6. for row_idx in range(sheet.nrows):
  7. for col_idx in range(sheet.ncols):
  8. cell = sheet.cell(row_idx, col_idx)
  9. print(cell.value, end="\t")
  10. print()

Where to learn more?

http://www.python-excel.org/