Ejemplo n.º 1
0
from xlwt import Workbook
input_file = sys.argv[1]
output_file = sys.argv[2]
output_workbook = Workbook()
output_worksheet = output_workbook.add_sheet('set_of_worksheets')
my_sheets = [0,1]
threshold = 1900.0
sales_column_index = 3
first_worksheet = True
with open_workbook(input_file) as workbook:
    data = []
    for sheet_index in range(workbook.nsheets):
        if sheet_index in my_sheets:
            worksheet = workbook.sheet_by_name(sheet_index)
            if first_worksheet:
                header_row = workbook.row_values(0)
                data.append(header_row)
                first_worksheet = False
            for row_index in range(workbook.nrows):
                row_list = []
                sales_amount = worksheet.cell_value(row_index, sales_column_index)
                if sales_amount > threshold:
                    for col_index in range(worksheet.ncols):
                        cell_value = worksheet.cell_value(row_index, col_index)
                        cell_type = worksheet.cell_type(row_index, col_index)
                        if cell_type == 3:
                            date_cell = xldate_as_tuple(cell_value, workbook.datemode)
                            date_cell = date[*date_cell[0:3]].strftime('%m/%d/%Y')
                            row_list.append(date_cell)
                        else:
                            row_list.append(cell_value)