Skip to content

Commit da81c6a

Browse files
committed
Handle column conversion more gracaefully
1 parent f4bc0d8 commit da81c6a

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2525

2626
### Fixed
2727

28-
- ...
28+
- `fiboa create-geoparquet`: Handle column conversion more gracaefully
29+
- `fiboa validate`: Don't fail collection test if something unexpected happened
2930

3031
## [v0.3.0] - 2024-04-10
3132

fiboa_cli/const.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pandas as pd
44

55
# fiboa datatypes to geopandas datatypes
6+
# todo: check whether it's better to use nullable Ints (e.g. Int64 instead of int64)
67
GP_TYPE_MAP = {
78
"boolean": "bool",
89
"int8": "int8", # todo add enum support - start

fiboa_cli/parquet.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,15 @@ def update_dataframe(data, columns, schema):
104104
continue
105105

106106
gp_type = GP_TYPE_MAP.get(dtype)
107-
if gp_type is None:
108-
log(f"{column}: No type conversion available for {dtype}")
109-
elif callable(gp_type):
110-
data[column] = gp_type(data[column])
111-
else:
112-
data[column] = data[column].astype(gp_type)
107+
try:
108+
if gp_type is None:
109+
log(f"{column}: No type conversion available for {dtype}")
110+
elif callable(gp_type):
111+
data[column] = gp_type(data[column])
112+
else:
113+
data[column] = data[column].astype(gp_type)
114+
except Exception as e:
115+
log(f"{column}: Can't convert to {dtype}: {e}", "warning")
113116

114117
return data
115118

0 commit comments

Comments
 (0)