コード例 #1
0
    def test_clean_time_index_case5b(self):

        wb = load_workbook(
            os.path.join(abs_path("original"), "test_case5b.xlsx"))
        ws = wb.active

        params = {"alignment": "vertical",
                  "time_alignment": 0,
                  "time_format": str,
                  "time_header_coord": ["A18", "B18"],
                  "data_starts": 28,
                  "data_ends": 993,
                  "frequency": "M",
                  "missings": True,
                  "missing_value": None,
                  "time_multicolumn": True,
                  "continuity": False,
                  "time_composed": True}

        CleanMultipleColumns()._clean_time_index(ws, params)

        wb_exp = load_workbook(
            os.path.join(abs_path("expected"), "test_case5.xlsx"))

        # wb.save("test_case5b_after_cleaning_index.xlsx")
        self.assertTrue(compare_cells(wb, wb_exp))
コード例 #2
0
    def test_clean_time_index_case6_without_end(self):

        wb = load_workbook(
            os.path.join(abs_path("original"), "test_case6.xlsx"))
        ws = wb.active

        params = {"alignment": "horizontal",
                  "blank_rows": True,
                  "composed_headers": True,
                  "data_starts": 3,
                  "data_ends": None,
                  "frequency": "AQQQQ",
                  "headers_coord": "B8-B28",
                  "continuity": False,
                  "missings": False,
                  "missing_value": None,
                  "multifrequency": True,
                  "series_names": None,
                  "time_composed": True,
                  "time_alignment": 0,
                  "time_multicolumn": True,
                  "time_format": str,
                  "time_header": True,
                  "time_header_coord": ["C4", "C6"]}

        end = CleanMultiColumnsMultiFreq().clean_time_index(ws, params)

        wb_exp = load_workbook(
            os.path.join(abs_path("expected"), "test_case6.xlsx"),
            data_only=True)

        # wb.save("test_case6_after_cleaning_index.xlsx")
        self.assertTrue(compare_cells(wb, wb_exp))
        self.assertEqual(end, 61)
コード例 #3
0
    def test_clean_time_index_case7(self):

        wb = load_workbook(
            os.path.join(abs_path("original"), "test_case7.xlsx"))
        ws = wb.active

        params = {"alignment": "horizontal",
                  "blank_rows": True,
                  "composed_headers": False,
                  "data_starts": 2,
                  "data_ends": 44,
                  "frequency": "A",
                  "continuity": False,
                  "missings": False,
                  "missing_value": "None",
                  "multifrequency": False,
                  "series_names": "None",
                  "time_composed": True,
                  "time_alignment": 0,
                  "time_multicolumn": False,
                  "time_format": int,
                  "time_header": False,
                  "time_header_coord": "A6"}

        CleanSingleColumn().clean_time_index(ws, params)

        wb_exp = load_workbook(
            os.path.join(abs_path("expected"), "test_case7.xlsx"),
            data_only=True)

        # wb.save("test_case5_after_cleaning_index.xlsx")
        self.assertTrue(compare_cells(wb, wb_exp))
コード例 #4
0
    def test_clean_time_index_case5_without_end(self):

        wb = load_workbook(
            os.path.join(abs_path("original"), "test_case5.xlsx"))
        ws = wb.active

        params = {"alignment": "vertical",
                  "time_alignment": 0,
                  "time_format": str,
                  "continuity": False,
                  "blank_rows": True,
                  "time_header_coord": "A18",
                  "data_starts": 28,
                  "data_ends": None,
                  "frequency": "M",
                  "missings": True,
                  "missing_value": None,
                  "time_multicolumn": False,
                  "time_composed": True}

        end = CleanSingleColumn().clean_time_index(ws, params)

        wb_exp = load_workbook(
            os.path.join(abs_path("expected"), "test_case5_without_end.xlsx"))

        # wb.save("test_case5_after_cleaning_index.xlsx")
        self.assertTrue(compare_cells(wb, wb_exp))
        self.assertEqual(end, 1001)
コード例 #5
0
    def test_clean_time_index_case2(self):

        wb = load_workbook(
            os.path.join(abs_path("original"), "test_case2.xlsx"))
        ws = wb.active

        params = {"alignment": "vertical",
                  "time_alignment": 0,
                  "time_format": datetime.datetime,
                  "continuity": True,
                  "blank_rows": True,
                  "time_header_coord": "C4",
                  "data_starts": 5,
                  "data_ends": 2993,
                  "frequency": "D",
                  "missings": True,
                  "missing_value": "Implicit",
                  "time_multicolumn": False,
                  "time_composed": False}

        CleanSingleColumn().clean_time_index(ws, params)

        wb_exp = load_workbook(
            os.path.join(abs_path("expected"), "test_case2.xlsx"))

        # wb.save("test_case2_after_cleaning_index.xlsx")
        self.assertTrue(compare_cells(wb, wb_exp))
コード例 #6
0
ファイル: test_xl_methods.py プロジェクト: leobelen/xlseries
    def test_open_xls_as_xlsx(self):
        wb_xls = open_xls_as_xlsx(abs_path("sh_ipcnu.xls"))
        wb_exp = load_workbook(os.path.join(abs_path("expected"),
                                            "sh_ipcnu.xlsx"),
                               data_only=True)

        self.assertTrue(compare_cells(wb_xls, wb_exp))
コード例 #7
0
ファイル: test_xl_methods.py プロジェクト: leobelen/xlseries
 def test_make_wb_copy(self):
     wb = load_original_case(2)
     wb_copy = make_wb_copy(wb)
     self.assertTrue(compare_cells(wb, wb_copy))