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:
committed by
GitHub
parent
fc4619f1ba
commit
a78e2df8f7
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user