示例#1
0
    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)
示例#2
0
 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)
示例#3
0
 def test_read_xls_no_file(self):
     get_dataframe_from_xls('bogus_file')
示例#4
0
 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'])
示例#5
0
 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
示例#6
0
 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)