Forum Documentation Showcase Pricing Learn more

CSV File to JSON

#1

Can any one guide me how to implement https://www.papaparse.com/ into bubble? I am trying to convert csv files to json so I can send the json reulsts as a POST request to bubble’s endpoint to create a new things.

I cant do a straight CSV upload because the headers in bubble’s DB do not match the fields in the database.

2 Likes

#2

Hi Shawn,

I’m in the same boat!

Would love for someone to help with this question! :pray:

Edit 1:
Here is a reply showing where to insert the script:

Edit 2:
Script can be added at page level:

0 Likes

#3

Hi, I actually figured it out using Papa Parse but then realized that it didn’t have any validation functions so I went with Flatfile.io

2 Likes

#4

Hi @shawn.chaudhery What is the best way you found to implement flatfile inside bubble?

0 Likes

#5

I took the scripts found on the Flatfile.io installation guide and placed them in the header of the page and I used the JavaScript plugin to execute the Script which triggers the file upload wizard which comes directly from Flatfile.io

Flatfile.io can be expensive so if you do not need the validation functionality then I suggest going with Papaparse considering it’s free.

2 Likes

#6

Thanks @shawn.chaudhery!

Talking about html header, do you put the script in here?

Otherwise with Papaparse, I kept on having an error telling me that “Papa is not defined”.
So I’ve ended up putting the script in a HTML element:
25

Thanks

0 Likes

#7

Yea the Page HTML Header is where it goes, make sure you have Papa Parse dependency (Library) linked to the page or else you will get that error of it not being defined. Download the library from the papaparse website and you can upload it to root folder of your bubble app under the settings tab.

0 Likes

#8

Are you able to retrieve any error with papaparse? I created a file with some mistakes, and I got error inside the browser (Chrome editing mode) not within the plugin error value.

0 Likes

#9

Uploaded the library to the root folder (Click view which will open the url address for the file copy that)

Put in the script tags in the Page Header using the url of the library which is now in your root folder

Using the Run JavaScript plugin crate a workflow which would trigger the papaparse script. I wanted the csv file to be parsed as json and then send a POST request to one of the API workflows I had created. The “Missing Value” is where you reference the file uploaded field. I needed to pass along more information then just the csv data whichis why I have the Batch ID and user info part of the script. Make sure to change the “POST”, to point towards your own workflow and make sure to add your bubble Api key in the Header: Bearer

1 Like

#10

Interesting, thanks. Will try that.

0 Likes

#11

I was able to console.log the errors in chrome, but I didn’t test much further as I switched to Flatfile.io

1 Like

#12

You can also use Integromat. They have a CSV parser and a JSON Aggregator.
This may be a little bit hard to understand how to set your json aggregator. So let me know if you try and have trouble

0 Likes

#13

Hi @shawn.chaudhery,

I have to implement Flatfile (papaparse plugin jammed with big file…). How do you implement it if you can share? They are looking to create a plugin, but until then… or PM if you can.

0 Likes

#14

Once you login to the Flatfile.io dashboard they have a generated script for you which you copy and paste into the Page HTML Header. Do you know how to configure your field? If not just DM me the generated script from the Dashboard and the fields you want and I can add those fields in your script to paste in your page. You will need to add any of the Run Javascript plug-ins to trigger the Flatfile wizard

Papaparse has a configuration option which you can enable if your processing large files, how many records where in the file which jammed up the page?

0 Likes

#15

I was using the paparse plugin (no option of processing large files). I suspect bubble problem or my file to be corrupted (was working fine couple of days ago…) Will look at that later. For flatfile, yes I had configured my fields. Once the script is in page html header (done), how do you execute flatfile wizard (via Run javascript the button onclick)? How you get back the data?

0 Likes

#16

Remove the button tag with the import function from the script (Line 1).

Create a button/element or whatever you want to trigger the flatfile wizard in bubble and add a action of “Run Javascript” (assuming you installed the plugin) and past the code from Line 33 to Line 38 from the first image your shared.

importer.requestDataFromUser().then(function(results) {
console.log(results.data)
// do something with the clean data here like upload it to your server
}, function() {
// do something if the user closes the importer
})

You should be able to see the results in your console log (chrome browser).

What would like to do with the data? you can use the Javascript to Bubble tool to take that data and send it via API to your bubble endpoint or you can make the API call right from the script using Javascript…

If you run into a issue, you can share the editor with me and I can help out.

1 Like

#17

Make sense :slight_smile:
thanks.

0 Likes

#18

Also if you decide to go back to Papaparse the option to enable was called “worker: ture” - here is the link to the option https://www.papaparse.com/faq#workers

*You also have to enable the “stream” option - https://www.papaparse.com/faq#streaming

1 Like