Click here to Skip to main content
Rate this: bad
good
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
table1
------------
mobilenumber,   name
919908999775,   sateee
919032540535,   say
919908999967,   saj
 
table2
-------
919908999775,   sateee
 
pleasehelp me thanks advance......
Posted 27-Aug-14 5:40am
Edited 27-Aug-14 5:57am
Nelek63.2K
v2
Comments
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
good
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.
  Permalink  
Comments
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 240
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


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