Quick script to convert json data to csv

I often need to dump data from a database to csv. This little snippet should make it easy enough to do without having to worry too much about character encodings, though it does assume you want your csv file to be utf-8 encoded.

Note that this dumps just one table from the database. Trying to dump all the tables in your app will raise an exception.