Beispiel #1
0
 def test_simple(self):
     make_simple(get_table(), "tst1.xlsx")
     result = import_xlsx_tables("tst1.xlsx")
     t = result['worksheets'][0][0]
     assert (t['headers'] == ['sample ID', 'line ID', 'replica', 'molecule1', 'molecule 2'])
     assert (t['values'] == [
         ['abcd1', 'line1', 1, 5.5, 6.5],
         ['abcd2', 'line1', 2, 4, 7.3],
         ['abcd3', 'line2', 1, 3.5, 8.8],
         ['abcd4', 'line2', 2, 2, 9.6]])
     result2 = import_xlsx_tables(
         "tst1.xlsx",
         worksheet_name="tst1.xlsx",
         column_search_text="sample",
     )
     t2 = result2['worksheets'][0][0]
     assert t2 == t
     result3 = import_xlsx_table("tst1.xlsx")  # note different function
     assert result3 == t
     result4 = import_xlsx_table(
         "tst1.xlsx", column_labels=["sample id", "molecule1", "MOLECULE 2"])
     assert (result4 == {
         'headers': ['sample ID', 'molecule1', 'molecule 2'],
         'values': [['abcd1', 5.5, 6.5],
                    ['abcd2', 4, 7.3],
                    ['abcd3', 3.5, 8.8],
                    ['abcd4', 2, 9.6]]})
     os.remove("tst1.xlsx")
Beispiel #2
0
 def test_error_handling(self):
     t3 = get_table()
     t3[7][1] = None
     make_simple(t3, "tst3.xlsx")
     result = import_xlsx_tables("tst3.xlsx")
     assert (result == {
         'worksheets': [
             [{
                 'headers': ['sample ID', 'line ID', 'replica', 'molecule1', 'molecule 2'],
                 'values': [
                     ['abcd1', 'line1', 1, 5.5, 6.5],
                     ['abcd2', 'line1', 2, 4, 7.3],
                     [None, 'line2', 1, 3.5, 8.8],
                     ['abcd4', 'line2', 2, 2, 9.6],
                 ]
             }, ],
         ],
     })
     # ask for missing worksheet
     try:
         import_xlsx_table("tst3.xlsx", worksheet_name="foo")
     except KeyError:
         pass
     else:
         assert False
     os.remove("tst3.xlsx")
Beispiel #3
0
def skyline_excel_parser(request):
    parser = skyline.SkylineParser()
    spreadsheet = excel.import_xlsx_tables(file=request)
    return ParsedInput(ImportFileTypeFlags.EXCEL,
                       parser.getRawImportRecordsAsJSON(spreadsheet))
Beispiel #4
0
def excel_parser(request):
    return ParsedInput(ImportFileTypeFlags.EXCEL,
                       excel.import_xlsx_tables(file=request))