Page 1 of 1

Import CSV data does not work as expected

Posted: 2023-09-27 15:27
by dannybridi
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

Re: Import CSV data does not work as expected

Posted: 2023-09-27 18:41
by jsetzer
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).

Re: Import CSV data does not work as expected

Posted: 2023-10-05 23:21
by dannybridi
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.