Filter CSV file for duplicates upon importing

  • Follow


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.

0
Reply shmoussa 6/14/2007 7:12:38 PM

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)
-- 
Good Luck  :-)

Graham Mandeno [Access MVP]
Auckland, New Zealand

"shmoussa" <shmoussa@gmail.com> wrote in message 
news:1181848358.843214.298970@e9g2000prf.googlegroups.com...
> 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.
> 


0
Reply Graham 6/14/2007 11:15:13 PM


1 Replies
469 Views

(page loaded in 0.025 seconds)

Similiar Articles:
















7/23/2012 3:07:28 PM


Reply: