Click here to Skip to main content
15,898,987 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
any one have the code for join two text file and update the duplicate line by column1 and column 2
Posted
Updated 11-Oct-12 12:50pm
v4
Comments
Christian Graus 25-Aug-12 12:51pm    
I'm going cross eyed trying to work out your business rules, but you're saying you want to remove data from a text file, or just insert different data ? You need to parse the data to apply your rules, and if you want to edit a text file, you need to read all of it in to memory, change it to be what you want, and write it all out again.
Christian Graus 25-Aug-12 17:39pm    
You need to create classes for the two formats, then you need to read the files in to arrays of those classes. Then you can work with them in memory and write them out. You need to hide the details of your file format in to one method, then you can calculate the rest from there. If one object exists as a collection inside another ( like say a parent has many children ) then put a list of one type inside the other class, so you can add them as you go. I didn't read this hige code dump, but that's what you need to do to make this code managable.
Christian Graus 25-Aug-12 18:51pm    
If you're new to programming, this is a complex task. I assume therefore it's for a class, no-one should be paying you to code. So, talk to your teacher, then he can know you're struggling, and give you one on one help.
Christian Graus 25-Aug-12 20:56pm    
I'm not sure what your point is. If you're teaching yourself, then slow down, you've chosen a task that is complex and as no-one is waiting for this code, you can take a step back and learn at your own level and pace.
Christian Graus 26-Aug-12 7:13am    
Well, again, if you're teaching yourself, why do you need to perform this task ? You should not be learning and charging for your work at the same time. I can only suggest the same thing again. Create a class that represents the objects that are in this file. Then read the data from this file in to a list of objects. Then you will have a clean framework to work with. You can read two lists of objects in to memory from two files, then you can compare those objects in memory and write out a final list when you're done.

1 solution

You need to create classes for the two formats, then you need to read the files in to arrays of those classes. Then you can work with them in memory and write them out. You need to hide the details of your file format in to one method, then you can calculate the rest from there. If one object exists as a collection inside another ( like say a parent has many children ) then put a list of one type inside the other class, so you can add them as you go. I didn't read this hige code dump, but that's what you need to do to make this code managable.
 
Share this answer
 
Comments
Dave Kreskowiak 11-Oct-12 22:38pm    
Countered the idiotic 1-vote...

Did this guy just remove every reply he posted, 'cause it looks like you're talking to yourself?
fjdiewornncalwe 11-Oct-12 23:09pm    
Didn't you know that Christian likes to talk to himself? :)

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