Skip to content
Snippets Groups Projects

FIX: Use openpyxl instead of xlrd

Merged Florian Spreckelsen requested to merge f-openpyxl into dev
1 file
+ 17
1
Compare changes
  • Side-by-side
  • Inline
+ 17
1
@@ -77,7 +77,8 @@ class ConverterTest(unittest.TestCase):
@@ -77,7 +77,8 @@ class ConverterTest(unittest.TestCase):
# TODO datatypes are different; fix it
# TODO datatypes are different; fix it
assert df.d.iloc[0] == datetime.datetime(1980, 12, 31, 13, 24, 23)
assert df.d.iloc[0] == datetime.datetime(1980, 12, 31, 13, 24, 23)
def test_date(self):
def test_date_xlsx(self):
 
"""Test with .xlsx in order to check openpyxl engine."""
test_file = os.path.join(os.path.dirname(__file__), "date.xlsx")
test_file = os.path.join(os.path.dirname(__file__), "date.xlsx")
self.importer = XLSImporter(converters={'a': date_converter,
self.importer = XLSImporter(converters={'a': date_converter,
'b': date_converter,
'b': date_converter,
@@ -91,6 +92,21 @@ class ConverterTest(unittest.TestCase):
@@ -91,6 +92,21 @@ class ConverterTest(unittest.TestCase):
assert df.shape[0] == 2
assert df.shape[0] == 2
assert df.a.iloc[0] == df.b.iloc[0] == df.c.iloc[0]
assert df.a.iloc[0] == df.b.iloc[0] == df.c.iloc[0]
 
def test_date_xls(self):
 
"""Test with .xlsx in order to check xlrd engine."""
 
test_file = os.path.join(os.path.dirname(__file__), "date.xls")
 
self.importer = XLSImporter(converters={'a': date_converter,
 
'b': date_converter,
 
'c': partial(date_converter,
 
fmt="%d.%m.%y")
 
}, obligatory_columns=['a'])
 
 
xls_file = pd.io.excel.ExcelFile(test_file)
 
df = xls_file.parse()
 
df = self.importer.read_xls(test_file)
 
assert df.shape[0] == 2
 
assert df.a.iloc[0] == df.b.iloc[0] == df.c.iloc[0]
 
def test_inc_date(self):
def test_inc_date(self):
incomplete_date_converter("2020", fmts={"%Y": "%Y"}) == "2020"
incomplete_date_converter("2020", fmts={"%Y": "%Y"}) == "2020"
incomplete_date_converter("02/2020",
incomplete_date_converter("02/2020",
Loading