Skip CSV row with invalid coordinates (#967)

* Skip CSV row with invalid coordinates

* Use single quotes and message string in a variable
This commit is contained in:
Jorge Martínez Gómez
2022-08-27 12:14:58 +02:00
committed by GitHub
parent fc4619f1ba
commit a78e2df8f7
+10 -4
View File
@@ -110,15 +110,21 @@ class CSVProvider(BaseProvider):
return feature_collection
LOGGER.debug('Slicing CSV rows')
for row in itertools.islice(data_, offset, offset+limit):
try:
coordinates = [
float(row.pop(self.geometry_x)),
float(row.pop(self.geometry_y)),
]
except ValueError:
msg = f'Skipping row with invalid geometry: {row.get(self.id_field)}' # noqa
LOGGER.error(msg)
continue
feature = {'type': 'Feature'}
feature['id'] = row.pop(self.id_field)
if not skip_geometry:
feature['geometry'] = {
'type': 'Point',
'coordinates': [
float(row.pop(self.geometry_x)),
float(row.pop(self.geometry_y))
]
'coordinates': coordinates
}
else:
feature['geometry'] = None