How do I import CSV data into table with data already in it?

How can I import a csv into a table that already has data and have only the new data in the CSV added to the table?

I tried using event handlers to trigger two JSON as SQL queries in series. The first to grab the existing data from the table, and the second to union the data from the first to the new data coming in from the newly loaded CSV.

What I'd like is load 13234_db.csv to table1 only grabbing the column custID and ignoring the rest > load 97493_db.csv once again only grabbing that same custID column and ignoring the rest > have only the new data from the 2nd CSV added into the table and leaving the data from the first CSV upload untouched.

I.e. 13234_db.csv contains:
custID
7823
2344
2345
6454

and 97493_db.csv contains:
custID
3453
6545
2345
6454

and after uploading both the table1 would show:
custID
7823
2344
2345
6454
3453
6545

How do I do this?

@WouldntItBeNice

From what I am understanding, you want to add data from two different CSV files into a table, and only show the unique data. I created two CSVs with the example data you offered and parsed them both though File Button components.

In a query I then joined the two CSVs with UNION to grab distinct values.


Finally, I added the data from the query to my table!

Is this what you are looking to do or are you wanting to continuously add and union CSVs to this table? If so, the set up may look a little different and we would be happy to walk you through that process :smile:

Thank you!

I was after the "wanting to continuously add and union CSVs to this table" scenario, but I think I just solved it by loading the existing table data into a temp state and running a union query that then updates the table.

It seems to work pretty well/fast, but If there's a better way to do this, I'm all ears.

1 Like

@WouldntItBeNice

Awesome! That's exactly what I would have suggested :dancer: