def _parse_template(self, template_xls): """Read template xls. Save the data and sheets in TapeWriter""" self.template_df = get_dataframe_from_xls(template_xls) logging.info('Loaded template from file: %s', template_xls) # Make sure other sheets in the template are copied book = load_workbook(template_xls) self.writer.book = book self.writer.sheets = dict((ws.title, ws) for ws in book.worksheets)
def test_read_xls_bad_format(self): not_xls_file = os.path.join(test_files_dir, 'not_excel_file.txt') get_dataframe_from_xls(not_xls_file)
def test_read_xls_no_file(self): get_dataframe_from_xls('bogus_file')
def test_read_excel(self): xls_file = os.path.join(test_files_dir, 'test_tape.xlsx') my_df = get_dataframe_from_xls(xls_file) eq_(my_df.columns.tolist(), ['aa', 'bb', 'E', 'dd']) eq_(my_df.iloc[1].tolist(), [43.5, 'FkdV', 4356, 'Beth Yarn'])
def setup_class(cls): """Create a Tape populated with some real looking data""" input_xls = os.path.join(test_files_dir, 'test_tape_format_1.xlsx') df = get_dataframe_from_xls(input_xls) cls.tape = Tape() cls.tape.dataframe = df
def read_xls(self, input_xls): """Read a Tape excel file and save as a DataFrame""" self.dataframe = get_dataframe_from_xls(input_xls) logging.info('Tape data parsed from %s', input_xls)