Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Updated 27-Aug-14 4:57am
v2
Comments
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"?)
sateesh kumar nemalikanti 12-Sep-14 9:59am    
hi nelek i just need to update if duplicates are there. any way thanks ihave solved it

1 solution

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.
 
Share this answer
 
Comments
sateesh kumar nemalikanti 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900