示例#1
0
 def clean_excel(self):
     excel = self.cleaned_data['excel']
     try:
         parse_xlsx(excel)
     except RuntimeError:
         raise ValidationError('excel file is malformed')
     except BadZipfile:
         raise ValidationError('excel file is not an excel(xlsx) file')
     return excel
示例#2
0
    def test_parse_xlsx(self):
        plot_type, labels, data = parse_xlsx(os.path.join(TEST_DATA,
                                                          'columns.xlsx'))
        assert plot_type == COLUMNS
        assert data[YVALUES] == [1.0, 3.0, 4.0, 5.0, 5.0]
        assert labels[XLABEL] == 'xlabel2'
        plot_type, labels, data = parse_xlsx(os.path.join(TEST_DATA,
                                                          'scatter.xlsx'))
        plot_type = SCATTER
        assert data[YVALUES] == [1.0, 3.0, 4.0, 5.0, 5.0]

        assert labels[XLABEL] == 'xlabel1'
def combined_experiment_excel_data(experiments_by_type):
    for type_name, exps in experiments_by_type.items():
        excel_data = {}
        for exp in exps:
            for excel_prop in exp.excel_props:
                exp_name = excel_prop.experiment.uniquename
                plot_type, labels, data = parse_xlsx(excel_prop.excel.path)
                if plot_type != COLUMNS:
                    continue
                excel_data[exp_name] = labels, data

        yield type_name, excel_data
示例#4
0
 def test_empty_file_excel(self):
     _, labels, data = parse_xlsx(os.path.join(TEST_DATA, 'empty_file.xlsx'))
示例#5
0
 def test_draw_scatter(self):
     _, labels, data = parse_xlsx(os.path.join(TEST_DATA, 'scatter.xlsx'))
     out_fhand = NamedTemporaryFile(suffix='.svg')
     draw_scatter(labels, data, out_fhand)
     raw_input(out_fhand.name)