diff --git a/geoclustering/encoding.py b/geoclustering/encoding.py index 352bc12..f1fad74 100644 --- a/geoclustering/encoding.py +++ b/geoclustering/encoding.py @@ -89,6 +89,7 @@ class CSVEncoder: self.state, fieldnames=["cluster_id"] + list(cluster[0].keys()), quoting=csv.QUOTE_NONNUMERIC, + lineterminator="\n", ) self.writer.writeheader() diff --git a/tests/encoding.py b/tests/encoding.py index 2be0638..8609128 100644 --- a/tests/encoding.py +++ b/tests/encoding.py @@ -27,3 +27,4 @@ def test_encoders(): assert res["string"] == read_fixture_content("snapshots/result.txt") assert res["json"] == read_fixture_content("snapshots/result.json") assert res["geojson"] == read_fixture_content("snapshots/result.geojson") + assert res["csv"] == read_fixture_content("snapshots/result.csv") diff --git a/tests/fixtures/snapshots/result.csv b/tests/fixtures/snapshots/result.csv new file mode 100644 index 0000000..0b5fa1e --- /dev/null +++ b/tests/fixtures/snapshots/result.csv @@ -0,0 +1,5 @@ +"cluster_id","id","name","lat","lon" +0,1,"Alice",52.523955,13.442362 +0,2,"Bob",52.526659,13.448097 +1,3,"Carol",52.525626,13.419246 +1,4,"Dan",52.52443559865125,13.41261723049818