Click here to Skip to main content
11,789,710 members (62,528 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#3.5 VB.NET .NET4
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
Edited 27-Aug-14 4:57am
Nelek at 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 at 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 at 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
0 OriginalGriff 999
1 Maciej Los 765
2 KrunalRohit 686
3 CPallini 606
4 Richard MacCutchan 430

Advertise | Privacy | Mobile
Web02 | 2.8.1509028.1 | Last Updated 27 Aug 2014
Copyright © CodeProject, 1999-2015
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