Import CSV data does not work as expected

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
dannybridi
Veteran Member
Posts: 54
Joined: 2016-03-21 19:33

Import CSV data does not work as expected

Post by dannybridi » 2023-09-27 15:27

Hi everyone,
I would like to import data from a CSV file, but only those records that already exist in my table. So, I checked (ticked) the "Update matching table records (using primary key) check box." Despite this, the application adds records where the primary key does not match.
To test, I created a CSV file with three lines: the header line, one line with an existing primary key, and one line with a primary key that does not exist in the table.
This results in updating the record with the existing primary key, but also creating a new record with the new primary key.
What am I doing wrong?
Thanks

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1817
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Import CSV data does not work as expected

Post by jsetzer » 2023-09-27 18:41

Hmmm, I think this is exactly the way it works (and should work for many use cases).

I'm afraid there is no standard way nor hook for importing (=updating) ONLY existing and skipping new records unless you code your own CSV-reader which eliminates "unknown" records before importing. Or you can delete "new" records afterwards (which I think is not good).
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

dannybridi
Veteran Member
Posts: 54
Joined: 2016-03-21 19:33

Re: Import CSV data does not work as expected

Post by dannybridi » 2023-10-05 23:21

Thanks jsetzer.
I ended up writing an excel macro that highlights the rows that don’t exist, and deleting them before the import.
That works fine.

Post Reply