Permalink
Browse files

Add missing tests and docs for in2csv.geojson.

  • Loading branch information...
1 parent c13ea6e commit cc228875c5650f1241b115095d0144858d126eb5 @onyxfish onyxfish committed Aug 24, 2012
Showing with 21 additions and 3 deletions.
  1. +7 −3 docs/scripts/in2csv.rst
  2. +14 −0 tests/test_convert/test_geojson.py
View
@@ -30,8 +30,8 @@ The header line is required though the columns may be in any order::
-h, --help show this help message and exit
-f FORMAT, --format FORMAT
The format of the input file. If not specified will be
- inferred from the filename. Supported formats: csv,
- dbf, fixed, json, xls, xlsx.
+ inferred from the file type. Supported formats: csv,
+ dbf, fixed, geojson, json, xls, xlsx.
-s SCHEMA, --schema SCHEMA
Specifies a CSV-formatted schema file for converting
fixed-width files. See documentation for details.
@@ -64,11 +64,15 @@ Standardize the formatting of a CSV file (quoting, line endings, etc.)::
$ in2csv examples/realdata/FY09_EDU_Recipients_by_State.csv
-Fetch csvkit's open issues from the Github API, convert the JSON response into a CSV, and write it to a file::
+Fetch csvkit's open issues from the Github API, convert the JSON response into a CSV and write it to a file::
$ curl https://api.github.com/repos/onyxfish/csvkit/issues?state=open | in2csv -f json -v > issues.csv
Convert a DBase DBF file to an equivalent CSV::
$ in2csv examples/testdbf.dbf > testdbf_converted.csv
+Fetch the ten most recent robberies in Oakland, convert the GeoJSON response into a CSV and write it to a file::
+
+ $ curl "http://oakland.crimespotting.org/crime-data?format=json&type=robbery&count=10" | in2csv -f geojson > robberies.csv
+
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+
+import unittest
+
+from csvkit.convert import geojs
+
+class TestGeoJSON(unittest.TestCase):
+ def test_dbf(self):
+ with open('examples/test_geojson.json', 'rb') as f:
+ output = geojs.geojson2csv(f)
+
+ with open('examples/test_geojson.csv', 'r') as f:
+ self.assertEquals(f.read(), output)
+

0 comments on commit cc22887

Please sign in to comment.