Uploading CSV and storing in a JS variable

I have some files I want to upload and then display them in tables. I understand how to do that from this article:

However, I want to be able to manipulate my data using javascript, and this method is calling the datasource for the tables directly from the parsed values of the filebuttons. I want to be able to set the datasource as a JS variable, it would probably be an array/JSON object.
How do I do that?

1 Like

Hello @lhc,

You can access the value with something like this:

let parsedData = fileDropzone1.parsedValue[0]

You can use this inside of a js query or transformer, manipulate the data at will, then return it and use it in the app!

Hope this helps!

1 Like

Thanks @GuilhermeSilva
I've written that in a JS query and had it trigger on click for the fileupload button, I then set the datasource to my table to the variable set (parsedData/named something else in my app) but it's saying that the value given is empty.

Hi @Ihc can we see a screenshot of the parsed data structure from the "State" tab?

Can you try it like this (on Parse instead of on Click)?

image

Then set you table datasource to parseData.data

Keep in mind parseData is the name for my JS query, replace it with the name of yours!

2 Likes


Here is the state of the parsed data @Tess

And I just changed the event to Parse @GuilhermeSilva but it still is saying my data source is empty.

Can you send a screenshot of where you are setting the variable/query value and a screenshot of the table datasource?

Here's the data source:
image
Here's my query:
image
And here's the event handler for the filebutton:
image

I believe you need to use artistData.data in the data source above.

And here you need to return the value either:

return fileButton1.parsedValue[0];

or

let artistData = fileButton1.parsedValue[0];
return artistData;
1 Like

Thank you @pyrrho, that worked!

2 Likes