Skip to content
Snippets Groups Projects
Commit 45384af9 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

FIX: Don't fail when datatype definitions don't occur in table

parent b150fdef
Branches
Tags
2 merge requests!112Release 0.12.0,!111F better csv value error
Pipeline #53500 passed
...@@ -546,6 +546,8 @@ class CSVImporter(TableImporter): ...@@ -546,6 +546,8 @@ class CSVImporter(TableImporter):
error_dict = {} error_dict = {}
columns_with_errors = [] columns_with_errors = []
for key, dtype in self.datatypes.items(): for key, dtype in self.datatypes.items():
if key not in df.columns:
continue
try: try:
df[key].astype(dtype) df[key].astype(dtype)
except (TypeError, ValueError): except (TypeError, ValueError):
......
...@@ -398,7 +398,8 @@ class CSVImporterTest(TableImporterTest): ...@@ -398,7 +398,8 @@ class CSVImporterTest(TableImporterTest):
kwargs = { kwargs = {
"datatypes": { "datatypes": {
"int": int, "int": int,
"float": float "float": float,
"not-in-table": str # An unused datatype definition must not cause problems.
}, },
"obligatory_columns": ["int"], "obligatory_columns": ["int"],
"converters": {} "converters": {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment