CSV file comparison

Hi all,

i have two .csv files. i need to compare those two files and if there is any difference that should be moved into third .csv file.

example,

org.csv and dup.csv

when we compare those two files org.csv and dup.csv. if there is any change in dup.csv. it should be capture in third file .

please help me on this.

thanks in advance...
baski

What those files look we dont know unless you post a sample of org.csv and dup.csv.

Are they in the same order? Will they ever have different numbers of lines? A simple solution for line-matching might just be:

diff a.csv b.csv | grep '^> ' | sed 's/> //' > diff-file

1 Like

Hi,

it has contain 51 colums.. with same order only..

actually i have 2 xml file and i m converting those xml files into csv. to compare those files.

it contains large data so i unable to post it..

thanks corona .. let me try that on.. but i need the difference should in .csv format

Thanks,
baski

Hi frnds,

Please help me out on the above issue..

thanks,
baski

The output was in CSV. Have you tried it to see if it does what you want?

Try this:

grep -F -v -f CSV1 CSV2

It presumes sorted data and CSV2 file is with more lines.

May not be efficient for large files.

 
perl -ne '$hash{$_} .= @ARGV}{for (keys %hash){print if $hash{$_}!~/10$/}' csv1 csv2