import numpy as np import xlrd path = u'indicator8_2014_1.xlsx' # имя и путь к файлу wb = xlrd.open_workbook(path) # открываем файл и передаём его как объект в wb ''' Методы sheet_names показывает список имён доступных для работы листов файла''' sheets = wb.sheet_names() print 'MS Excel sheets:', sheets print type(sheets), len(sheets) ''' Передаём первый (и едиственный в данном случае) лист как объект sh ''' sh = wb.sheet_by_name(sheets[0]) print 'Sheet name:',sh.name # выведем имя текущего листа print 'Number of rows:',sh.nrows, 'Number of cells in choosed column:',len(sh.col(0)) # число строк разными способами print 'Number of columns:', sh.ncols, 'Number of cells in choosed row:', len(sh.row(0)) # число столбцов разными способами ''' Передаём колонки в виде списков year и temp ''' year = sh.col_values(0) # Важно передать именно values. Иначе* будет передан список из особого класса ячеек Cells temp = sh.col_values(1) # * ИНАЧЕ cell = sh.col(0)[0] print 'Type of cell', type(cell) print 'XL_CELL_TEXT 1 (Unicode string):', cell.ctype print 'Cell value:', cell.value cell = sh.col(0)[5] print 'XL_CELL_NUMBER 2 (float):', cell.ctype print 'Cell value:', cell.value print '----------------------------------------' print year print temp row1 = 6 row2 = 139 year = sh.col_values(0,row1,row2) temp = sh.col_values(1,row1,row2) import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) ax.plot(year,temp,'k-') ax.set_xlabel('Source: NASA GIS') ax.set_ylabel('Degrees Fahrenheit') ax.set_title('Average Global Temperature, 1880-2013') ax.grid(axis='y', color='k', linestyle='-', linewidth=0.5) plt.show()