From 6be7b98be83064138746cc4853bb8b82adf9b017 Mon Sep 17 00:00:00 2001
From: Florian Spreckelsen <f.spreckelsen@indiscale.com>
Date: Wed, 2 Jun 2021 06:52:43 +0000
Subject: [PATCH] FIX: Use openpyxl instead of xlrd

---
 CHANGELOG.md                                  |   1 +
 .../2010_TestProject/2019-02-03/README.md     |   2 +-
 .../2010_TestProject/2019-02-03/README.md     |   2 +-
 .../2019-02-03_really_cool_finding/README.md  |   2 +-
 .../2010_TestProject/2019-02-03/README.md     |   2 +-
 setup.py                                      |   1 +
 unittests/date.xls                            | Bin 0 -> 6144 bytes
 unittests/test_table_importer.py              |  18 +++++++++++++++++-
 8 files changed, 23 insertions(+), 5 deletions(-)
 create mode 100644 unittests/date.xls

diff --git a/CHANGELOG.md b/CHANGELOG.md
index dfba5bc0..5fbe3b97 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Fixed ###
 - 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
   cause an `sqlite3.IntegrityError` if more than one change was cached
   for the same entity.
diff --git a/integrationtests/extroot/DataAnalysis/2010_TestProject/2019-02-03/README.md b/integrationtests/extroot/DataAnalysis/2010_TestProject/2019-02-03/README.md
index ce0111b8..71454e89 100644
--- a/integrationtests/extroot/DataAnalysis/2010_TestProject/2019-02-03/README.md
+++ b/integrationtests/extroot/DataAnalysis/2010_TestProject/2019-02-03/README.md
@@ -1,7 +1,7 @@
 ---
 responsible:	
 - Only Responsible
-description: 	A description of this example analysis.
+description: 	A description of another example analysis.
 
 sources:
 - file:	"/ExperimentalData/2010_TestProject/2019-02-03/*.dat"
diff --git a/integrationtests/extroot/ExperimentalData/2010_TestProject/2019-02-03/README.md b/integrationtests/extroot/ExperimentalData/2010_TestProject/2019-02-03/README.md
index b9d7ef5e..b7e5051c 100644
--- a/integrationtests/extroot/ExperimentalData/2010_TestProject/2019-02-03/README.md
+++ b/integrationtests/extroot/ExperimentalData/2010_TestProject/2019-02-03/README.md
@@ -1,7 +1,7 @@
 ---
 responsible:	
 - Only Responsible
-description: 	A description of this example experiment.
+description: 	A description of another example experiment.
 
 results:
 - file:	"/ExperimentalData/2010_TestProject/2019-02-03/*.dat"
diff --git a/integrationtests/extroot/Publications/Posters/2019-02-03_really_cool_finding/README.md b/integrationtests/extroot/Publications/Posters/2019-02-03_really_cool_finding/README.md
index 6d378818..c95e37ec 100644
--- a/integrationtests/extroot/Publications/Posters/2019-02-03_really_cool_finding/README.md
+++ b/integrationtests/extroot/Publications/Posters/2019-02-03_really_cool_finding/README.md
@@ -1,7 +1,7 @@
 ---
 responsible:	
 - Only Responsible
-description: 	A description of this example experiment.
+description: 	A description of another example experiment.
 
 sources:
 - /DataAnalysis/2010_TestProject/2019-02-03/results.pdf
diff --git a/integrationtests/extroot/SimulationData/2010_TestProject/2019-02-03/README.md b/integrationtests/extroot/SimulationData/2010_TestProject/2019-02-03/README.md
index f978bb77..fba1bd48 100644
--- a/integrationtests/extroot/SimulationData/2010_TestProject/2019-02-03/README.md
+++ b/integrationtests/extroot/SimulationData/2010_TestProject/2019-02-03/README.md
@@ -1,7 +1,7 @@
 ---
 responsible:	
 - Only Responsible
-description: 	A description of this example experiment.
+description: 	A description of another example experiment.
 
 results:
 - file:	"*.dat"
diff --git a/setup.py b/setup.py
index 1d824f51..f26b126c 100755
--- a/setup.py
+++ b/setup.py
@@ -155,6 +155,7 @@ def setup_package():
         author='Henrik tom Wörden',
         author_email='h.tomwoerden@indiscale.com',
         install_requires=["caosdb>=0.4.0",
+                          "openpyxl>=3.0.0",
                           "pandas>=1.2.0",
                           "xlrd>=2.0",
                           ],
diff --git a/unittests/date.xls b/unittests/date.xls
new file mode 100644
index 0000000000000000000000000000000000000000..966ad4dc1d04055d75b455c8d0f9a5ac6f36200d
GIT binary patch
literal 6144
zcmca`Uhu)fjZzO8(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dh9uF{FXx1SC?zkjaqGkOxwT18YF-2h~2r+ONXEz_12t
z9xH<jLq0<?*bS-R5h&8!V*#}vWH$&yjm1l;GcYie;8j7IB*<PECPpV{oP!v3#HxYW
L4WfzBgKR$l?JPmF

literal 0
HcmV?d00001

diff --git a/unittests/test_table_importer.py b/unittests/test_table_importer.py
index 6681ed2c..51b4803d 100644
--- a/unittests/test_table_importer.py
+++ b/unittests/test_table_importer.py
@@ -77,7 +77,8 @@ class ConverterTest(unittest.TestCase):
         # TODO datatypes are different; fix it
         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")
         self.importer = XLSImporter(converters={'a': date_converter,
                                                 'b': date_converter,
@@ -91,6 +92,21 @@ class ConverterTest(unittest.TestCase):
         assert df.shape[0] == 2
         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):
         incomplete_date_converter("2020", fmts={"%Y": "%Y"}) == "2020"
         incomplete_date_converter("02/2020",
-- 
GitLab