Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 21st, 2011, 09:36 AM
akaballa123 akaballa123 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 23 akaballa123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 5 m 10 sec
Reputation Power: 0
[BASH] Help with Comparing two csv files

Hi, am a total newb to this,

I would like to compare two large csv files row by row and output any difference in the row to a third file that clearly states the row ID and the row data. I was wondering if there is a way to do that using bash script.

I researched the diff command wrote a command such as this:

Code:

diff -c file1.csv file2.csv >> test.csv


This code doesnt really output the differences properly.

Say file1 has:

Code:

RISK, PTFOLIO, FMLY, GRP, TYPE, NUM1
ALL, FUNDING, BR, IRD, US, -32702
ALL, FUNDING, BR, IRD, US, -40000
 


Say file2 has:

Code:

RISK, PTFOLIO, FMLY, GRP, TYPE, NUM1
ALL, FUNDING, BR, IRS, CA, -38001

 


the first row (RISK...) is the heading so I do not want to compare that. The Second row have 3 difference, so i want the output to test.csv as such

Code:

RISK, PTFOLIO, FMLY, GRP, TYPE, NUM1

[Row1 #]
ALL, FUNDING, BR, IRD, US, -32702
ALL, FUNDING, BR, IRS, CA, -38001

[Row2 #]
ALL+, FUNDING, BR, IRD, US, -40000



I believe this clearly highlights the difference. Thje plus sign in row2 highlights that this file was in only one file and not the other.

I also looked into the awk command, but am not fluent with it, so am not able to use to to create the comparison.

Am not sure if something like this can be done. Any ideas? Plz advice, thanks!!!

Regards,
ssampath[/QUOTE]

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > [BASH] Help with Comparing two csv files

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap