Click here to Skip to main content
13,093,720 members (59,743 online)
Rate this:
Please Sign up or sign in to vote.
how to segregate duplicate data and entire data in comma delimited text file i want to save data in two different tables and over ride duplicates
my text file is like below
mobilenumber,   name
919908999775,   sasa
919032540535,   say 
919908999775,   sateee
919908999967,   saj

now i need two tables like below
mobilenumber,   name
919908999775,   sateee
919032540535,   say
919908999967,   saj
919908999775,   sateee

pleasehelp me thanks advance......
Posted 27-Aug-14 4:40am
Updated 27-Aug-14 4:57am
Nelek 27-Aug-14 10:59am
In the first table the same mobile number is used twice, but with different names.
How do you know which one is the correct one? The last that appears? (That's why you are dismissing the name os "sasa"?)
Member 10618473 12-Sep-14 9:59am
hi nelek i just need to update if duplicates are there. any way thanks ihave solved it

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Don't try to mix two tables in the same file: use two different files and the task becomes pretty easy.
If you mix them, then you have to find a "clean" way to separate them, and that gets cumbersome.

So have two files "mytext.1.csv" and "mytext.2.csv" and read them both later.
To separate the data, sort it by the phone number - so duplicated values are next to each other - then open two output streams.
Loop through all lines, and if this is the first occurrence, write it to one stream, otherwise write it to the other.
Member 10618473 30-Aug-14 7:01am
thanks griff, i solved it my self

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 27 Aug 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100