Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Delimited files Comparisionby harishnuti (Beadle) |
on Jul 28, 2008 at 03:35 UTC ( [id://700448]=perlquestion: print w/replies, xml ) | Need Help?? |
harishnuti has asked for the wisdom of the Perl Monks concerning the following question: Hello Monks i need your advice on my below requirement and the suggestions on effort i put to achieve it * i have 2 delimited files which needs to be compared * The headers for this delimited files is present in another file * i need to skip some fields while comparision * finally i should print the differences between these 2 delimited files i.e. only fields which are different along with header in good report format. A Extract of File1 shown below !A90000!,!B00500!,!1!,!0!,!2!,!23/02/1998!,!2!,!1!,!B005AU! !A90000!,!B00500!,!2!,!0!,!2!,!23/02/1998!,!2!,!1!,!B005AU! !A90000!,!B00500!,!3!,!0!,!2!,!23/02/1998!,!2!,!1!,!B005AU! !A90000!,!B00500!,!4!,!0!,!2!,!23/02/1998!,!2!,!1!,!B005AU! !I912ST!,!SG!,!30/08/2004!,!288!,!0! !I912ST!,!SN!,!30/08/2004!,!249!,!0! !I912ST!,!TR!,!30/08/2004!,!56!,!0! !I912ST!,!WC!,!30/08/2004!,!211!,!0! A Extract of file2 shown below !A90000!,!B00500!,!0!,!0!,!2!,!23/02/1998!,!2!,!1!,!B005AU! !A90000!,!B00500!,!3!,!0!,!2!,!23/02/1998!,!2!,!1!,!B005AU! !A90000!,!B00500!,!3!,!4!,!2!,!23/02/1998!,!2!,!1!,!B005AU! !A90000!,!B00500!,!4!,!0!,!8!,!23/02/1998!,!2!,!1!,!B005AU! !I912ST!,!SG!,!30/08/2004!,!248!,!0! !I912ST!,!SN!,!30/08/2004!,!290!,!0! !I912ST!,!FZ!,!30/08/2004!,!56!,!0! !I912ST!,!WC!,!30/08/2004!,!211!,!1! Header file will be below format A90000,CT03,1, 1,00240 A90000,CT03,1, 2,00020 A90000,CT03,1, 3,00090 A90000,CT03,1, 4,00690 A90000,CT03,0, 5,01040 A90000,CT03,0, 6,00241 A90000,CT03,0, 7,00243 A90000,CT03,0, 8,00710 A90000,CT03,0, 9,00242 I91200,CW5Y,1, 1,17447 I91200,CW5Y,0, 2,01040 I91200,CW5Y,0, 3,04010 I91200,CW5Y,0, 4,04620 and so on ..... A90000 , I91200 etc , need to generalize this solution The last column are header for the data in above files my Code below
i can paste the whole code, but its in pretty bad shape, if there is any better way to achieve above formatting, i love to know. iam happy even if any suggestions are given to achieve above formatting, i can try experimenting in my code
Back to
Seekers of Perl Wisdom
|
|