json to csv

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

json to csv

#1

Postby Steve James » Thu Jun 14, 2018 5:53 pm

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
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: json to csv

#2

Postby Segi » Mon Jun 18, 2018 11:18 pm

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
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

Re: json to csv

#3

Postby Steve James » Tue Jun 19, 2018 8:58 am

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 8 guests