compare files

"MOKRANI Rachid [email protected] [sed-users]" <[email protected]> Fri, 6 Jan 2017 12:55:35 +0000
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
Hi,

Before to ask my firts question of the year.
Happy new year to all !


Then,
I have some difficulties to compare two files with with many arguments.



File A.txt

henry;1;
christophe;1;
bill;1;
nathalie;2;
jane;2;
william;1;
dominique;1 2;
pierre-henry;1;


File B.txt

( 'TA', 'Christophe', 'Jane', 'Christophe', 'US', 'New York')
( 'XA', 'Dominique', 'Grant', 'Dominique', 'US', 'New York'),
( 'XA', 'Bill', 'Jane', 'Bill', 'US', 'New York'),
( 'BC', 'Nathalie', 'Portman', 'Nathalie', 'US', 'New York'),
( 'BC', 'Pierre', 'Robert', 'Pierre', 'US', 'New York'),
( 'XV', 'Jane', 'Fonda', 'Jane', 'IT', 'Roma'),
( 'HG', 'William', 'Jefferson', 'William', 'US', 'Chicago'),
( 'HG', 'Barberousse', 'Pirate', 'Barberousse', 'US', 'Chicago'),
( 'XA', 'Henry', 'Grant', 'Henry', 'US', 'Miami'),



In file B, if the EXACT content of the colum 4 exist in the first colum in the file A.txt, then replace it with the value of the second colum of the file A.txt . it should be only 1 OR 2

And

In file B, if the EXACT content of the colum 4 does not exist in the first colum in the file A.txt, then replace  the value of the fourth colum of the file B.txt  with 0 .




I hope to be clear...


Here is the expected result in the example I have just given


Need Result.
( 'TA', 'Christophe', 'Jane', '1', 'US', 'New York')
( 'XA', 'Dominique', 'Grant', '0', 'US', 'New York'),
( 'XA', 'Bill', 'Jane', '1', 'US', 'New York'),
( 'BC', 'Nathalie', 'Portman', '2', 'US', 'New York'),
( 'BC', 'Pierre', 'Robert', '0', 'US', 'New York'),
( 'XV', 'Jane', 'Fonda', '2', 'IT', 'Roma'),
( 'HG', 'William', 'Jefferson', '1', 'US', 'Chicago'),
( 'HG', 'Barberousse', 'Pirate', '0', 'US', 'Chicago'),
( 'XA', 'Henry', 'Grant', '1', 'US', 'Miami'),


Any suggestions ?

Best regards,
__________________________
Avant d'imprimer, pensez à l'environnement ! Please consider the environment before printing ! 
Ce message et toutes ses pièces jointes sont confidentiels et établis à l'intention exclusive de ses destinataires. Toute utilisation non conforme à sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. IFP Energies nouvelles décline toute responsabilité au titre de ce message. This message and any attachments are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. IFP Energies nouvelles should not be liable for this message.
__________________________


[Non-text portions of this message have been removed]