Posts

Showing posts from April, 2015

Python: Read data from spreadsheet.

[code language="python"] """ Spreadsheet with some definitions: |   |          A        |     B     |  C  | | 1 |    4/5/2014 13:34 | Apples    | 73  | | 2 |     4/5/2014 3:41 | Cherries  | 85  | | 3 |    4/6/2014 12:46 | Pears     | 14  | | 4 |     4/8/2014 2:07 | Apples    | 152 | """ # Install openpyxl: pip install openpyxl # code: >>> import openpyxl >>> import os >>> os.chdir('c:\\users\\all\\documents') # file located in folder "documents" >>> >>> >>> workbook = openpyxl.load_workbook('example.xlsx') >>> type(workbook) <class 'openpyxl.workbook.workbook.Workbook'> >>> sheet = workbook.get_sheet_by_name('Sheet1') >>> type(sheet) <class 'openpyxl.worksheet.worksheet.Worksheet'> >>> workbook.get_sheet_names() ['Sheet1', 'Sheet2', 'Sheet3'] >>> sheet['A1'...