Hi, has anyone got a great way to convert json to csv? Simple json, no nesting, just an array of kvp.
Client side I use https://www.papaparse.com/docs#json-to-csv. It works well and it works well server side (most of the time).
I'm investigating NoSQL as a data store (and it may be used for transactional forms). Data is stored as json objects and is schemaless so will be particularly useful for IoT data. The NoSQL db has REST end points so it fits nicely with Ebase.
I still need to offer an option to get a csv representation of a dataset as not all data users will be comfortable with JSON.
PapaParse works to a point (server side) but is taking 17 seconds to unparse 40k records whereas client side it takes less than a couple of seconds.
Thanks
json to csv
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
Re: json to csv
I did this exact same thing in one of my Verj projects.
Here's the function that takes JSON data as input along with a few other parameters, converts the JSON to CSV and saved the CSV to the filename that you specify as a parameter.
https://codepen.io/anon/pen/JZMyXz?editors=0010#0
Let me know if you need help understanding anything about how it works. Hopefully it should be really straight forward
Here's the function that takes JSON data as input along with a few other parameters, converts the JSON to CSV and saved the CSV to the filename that you specify as a parameter.
https://codepen.io/anon/pen/JZMyXz?editors=0010#0
Let me know if you need help understanding anything about how it works. Hopefully it should be really straight forward
0 x
-
- Ebase User
- Posts: 331
- Joined: Mon Mar 10, 2014 8:34 am
Re: json to csv
Great thanks Segi, I got a basic function up and running so it'll be good to see if yours runs faster.
0 x
Who is online
Users browsing this forum: No registered users and 9 guests