import xlrd file_location = "E:/FIRES.xls" workbook = xlrd.open_workbook(file_location) sheet = workbook.sheet_by_index(0) print (sheet.nrows) print (sheet.ncols) date = sheet.cell_value(1, 0) true = xlrd.xldate.xldate_as_datetime(date, workbook.datemode) check_year = str(true).split('-')[0] print (check_year) array_one = [] array_two = [] test = [] for row in range(1, sheet.nrows, 1): del array_two[:] for col in range(sheet.ncols): array_two.append(sheet.cell(row, col)) date = sheet.cell_value(row, 0) true = xlrd.xldate.xldate_as_datetime(date, workbook.datemode) year = str(true).split('-')[0] del array_two[0] array_two.insert(0, year) array_two.insert(0, true) array_one.append(array_two) if year == check_year: test.append(array_two) else: print (test) check_year = year test = []
Файл Эксел (слишком большой для вложения) https://drive.google.com/open?id=0B7_5i1doXsLSXzd2akl1cjQzQW8