Skip to content

Commit

Permalink
csvjson: Do not emit empty properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Jul 24, 2017
1 parent da1f330 commit acaf5ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion csvkit/utilities/csvjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def dump_json(data, newline=False):
max_lon = lon
elif i == id_column:
geoid = c
else:
elif c:
properties[table.column_names[i]] = c

if id_column is not None:
Expand Down
8 changes: 6 additions & 2 deletions tests/test_utilities/test_csvjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ def test_geojson(self):
for feature in geojson['features']:
self.assertEqual(feature['type'], 'Feature')
self.assertFalse('id' in feature)
self.assertEqual(len(feature['properties']), 10)
self.assertIn('properties', feature)
self.assertIsInstance(feature['properties'], dict)
self.assertGreater(len(feature['properties']), 1)

geometry = feature['geometry']

Expand All @@ -92,7 +94,9 @@ def test_geojson_with_id(self):
for feature in geojson['features']:
self.assertEqual(feature['type'], 'Feature')
self.assertTrue('id' in feature)
self.assertEqual(len(feature['properties']), 9)
self.assertIn('properties', feature)
self.assertIsInstance(feature['properties'], dict)
self.assertGreater(len(feature['properties']), 1)

geometry = feature['geometry']

Expand Down

0 comments on commit acaf5ce

Please sign in to comment.