troubleshooting Question

Need to compare 2 csv files and write the changes to a tab delimited file

Avatar of mytilig
mytilig asked on
Perl
6 Comments1 Solution182 ViewsLast Modified:
I have a need to compare 2 csv files file a and file b .
create an output file c that is tab delimited. This file should just have the records in file b that do not match file a.

Rules:
If the record is same in both file a and file b, and exactly same,  I do not need it in c
If the record is in file a, not in file b, I do not need it in c
If the record is in file a and file b, and atleast one column has different value, write the complete record as is in file b to file c.

Eg.

File a:
----------------

Id,username,Fname,Lname (this is a header line and should be present in all files)
1,user1,John,Doe
2,user2,Cathy,Smith
3,user3,Joe,Smoe

File b:
----------------

Id,username,Fname,Lname
2,user2,Cathy,Smith
3,user3,Joe,Palker
4,user4,John,Smith

In this case, Id#1 got dropped off in file b and also Id#4 got added. Also user3's last name changed.  So the output should look like

File c:

----------------

Id username Fname Lname
3  user3       Joe Palker
4  user4       John Smith

Note that my original file has 11 columns and I will have to check for data changes in each and every one of them.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros