onyxfish/csvkit — pull request #357 by jennifersmith (2014-11-04 02:04:10+00:00)
Title: Adding support for streaming json documents

This resolves issue #355 by adding a further option to csvjson that allows you to specify that you want to output a stream of newline delimited json object rather than an array of all objects.

To see this in action, consult the tests or:

```csvjson --stream examples/dummy3.csv```

Result:

```
{"a": "1", "b": "2", "c": "3"}
{"a": "1", "b": "4", "c": "5"}
```

Original:

```csvjson examples/dummy3.csv```

Result:

```
[{"a": "1", "b": "2", "c": "3"}, {"a": "1", "b": "4", "c": "5"}]
```

_Note:_ This will not work (and in fact error) if you to use the stream option alongside lat/lon/key options because all of these output a top level json object anyway.

Implementation notes:

I tried to keep the changes minimal, but I did extract dump_json to allow me to diversify where it was called from.

I am not too familiar with python. Tried to keep to conventions, but please feel free to met me know if you would like any improvements.