Skip to content
Snippets Groups Projects
Commit 6be7b98b authored by Florian Spreckelsen's avatar Florian Spreckelsen Committed by Henrik tom Wörden
Browse files

FIX: Use openpyxl instead of xlrd

parent 8fef480b
No related branches found
No related tags found
2 merge requests!22Release 0.3,!2FIX: Use openpyxl instead of xlrd
...@@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### ### Fixed ###
- An exception in collect_information does no longer lead to a break down. - An exception in collect_information does no longer lead to a break down.
- Removed dependency on discontiued xlrd version
* Fixed an issue where `caosadvancedtools.cache.UpdateCache` would * Fixed an issue where `caosadvancedtools.cache.UpdateCache` would
cause an `sqlite3.IntegrityError` if more than one change was cached cause an `sqlite3.IntegrityError` if more than one change was cached
for the same entity. for the same entity.
......
--- ---
responsible: responsible:
- Only Responsible - Only Responsible
description: A description of this example analysis. description: A description of another example analysis.
sources: sources:
- file: "/ExperimentalData/2010_TestProject/2019-02-03/*.dat" - file: "/ExperimentalData/2010_TestProject/2019-02-03/*.dat"
......
--- ---
responsible: responsible:
- Only Responsible - Only Responsible
description: A description of this example experiment. description: A description of another example experiment.
results: results:
- file: "/ExperimentalData/2010_TestProject/2019-02-03/*.dat" - file: "/ExperimentalData/2010_TestProject/2019-02-03/*.dat"
......
--- ---
responsible: responsible:
- Only Responsible - Only Responsible
description: A description of this example experiment. description: A description of another example experiment.
sources: sources:
- /DataAnalysis/2010_TestProject/2019-02-03/results.pdf - /DataAnalysis/2010_TestProject/2019-02-03/results.pdf
......
--- ---
responsible: responsible:
- Only Responsible - Only Responsible
description: A description of this example experiment. description: A description of another example experiment.
results: results:
- file: "*.dat" - file: "*.dat"
......
...@@ -155,6 +155,7 @@ def setup_package(): ...@@ -155,6 +155,7 @@ def setup_package():
author='Henrik tom Wörden', author='Henrik tom Wörden',
author_email='h.tomwoerden@indiscale.com', author_email='h.tomwoerden@indiscale.com',
install_requires=["caosdb>=0.4.0", install_requires=["caosdb>=0.4.0",
"openpyxl>=3.0.0",
"pandas>=1.2.0", "pandas>=1.2.0",
"xlrd>=2.0", "xlrd>=2.0",
], ],
......
File added
...@@ -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 .xls 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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment