Filter CSV file for duplicates upon importing

S

shmoussa

Hi. I am importing a CSV file into a new table using the open file
dialog box and an import specification.

There are four fields (A,B,C,D). I want to filter for duplicates so if
B,C,D are the same then only one of those records will be imported.
Here is an example:

Record 1 (A,B,C,D): John, Mapquest, 59, 62
Record 2 (A,B,C,D): Alex, Mapquest, 62, 81
Record 3 (A,B,C,D): Josh, Finepoint, 43, 65
Record 4 (A,B,C,D): John, Mapquest, 62, 81
Record 5 (A,B,C,D): John, Mapquest, 59, 62

So Record 4 will not be imported, because column B,C,D are the same as
Record 2.
Record 5 will not be imported because B,C,D are the same as Record 1.
I want to ignore column A.

Is this possible? How can I tell VB to do this?

Thanks for your help. Let me know if you don't fully understand what I
want.
 
G

Graham Mandeno

You are going to need to run a query on the import data to do this, so you
must first either import the data into a temporary table or attach the CSV
file as a linked table.

[Note that it's generally considered a Bad Idea to have temp tables in your
main front-end database. People deal with this in different ways but my
preference is to create temp tables in a temp database and link then in code
to the front-end]

Then you can create a "make table" query based on an aggregate query on your
data, grouping by B, C and D and using the First function to select the
value for A. (Note that the value returned by First is not always
predictable - for example records 2 and 4 could return either Alex or John)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top