Export data from parse.com in json and csv format using command line [Python]
12 August 2015By Bhavyanshu Parasher
I personally use parse.com as backend for a lot of projects so I thought it would be nice to have a command line tool which can export parse data to json & csv format. Those who want to export data to tar.bz2 format, look at parse-export. For csv or json you can use my modified script provided below. Note that it is not dependent on parse-export. You can independently use this script. I have edited the main method to generate a csv from json. Rest of it is pretty much a derivation from parse-export.
NOTE : It will work in most cases but if the field is of pointer/array type, then it will put the complete pointer type field value under single column. Also, no dependency issue. You might wanna pip install python-dateutil in case you are using the datautil.parser to convert date time to better readable format.
Code [Updated - 26/12/2015]
Update: Old script was comparing createdAt field and hence was stuck in loop. The updated code addresses that concern and has more functionality like using limit and skip functionality provided by parse API. Thanks to Janny for letting me know about this bug.
First you need to get the API keys. Open parse.com, login and select app. Go to settings, keys and copy the values of these three keys.
REST API Key
Insert these keys in the below provided script.
Save this script and execute it like
$ python whateverscriptname.py
It will output something like
*** Requesting... ***
Fetching User table data - Got: 6.0000 records in 0.0121 secs
Fetching Installation table data - Got: 11.0000 records in 0.0121 secs
This will generate .json and .csv files for respective classes. You can use cat command to view the data in these files. That’s all. Leave a comment below if you have any issue with it or want to suggest an improvement.