Discussion:
compare column
MOKRANI Rachid rachid.mokrani@ifpen.fr [sed-users]
2016-01-13 12:52:25 UTC
Permalink
Hi,

Still again I ask for your help for the example below.

In my file example below, I need to compare the column with the name "PHONE" with the column with the name "COMMENT"

If for a same line the field in the column "PHONE" is equal to "PHONE1" AND the field in column "COMMENT" is blank THEN replace the field blank by "MY PERSONAL COMMENT"
The file below is only for example. The original file, has more columns and more lines.


"id";"Company";"NAME ";"FIRSTNAME";"JOB";"Town";"PHONE";"COMMENT";

"111222333";"Company A";"NAME A ";"FIRSTNAME 1";"JOB 1";"Town 1";"PHONE 1";"COMMENT 1";

"111222334";"Company A";"NAME A ";"FIRSTNAME 4";"JOB 1";"Town 1";"PHONE 1";"";

"118822333";"Company B";"NAME T ";"FIRSTNAME 1";"JOB 2";"Town 2";"PHONE 65"; "COMMENT 1235";

"111275333";"Company C";"NAME M ";"FIRSTNAME 2";"JOB 7";"Town 1";"PHONE 6";"";

"55222334";"Company Y";"NAME G ";"FIRSTNAME 4";"JOB 52";"Town 1";"PHONE 1";"";



Need to obtain the result below.


"id";"Company";"NAME ";"FIRSTNAME";"JOB";"Town";"PHONE";"COMMENT";

"111222333";"Company A";"NAME A ";"FIRSTNAME 1";"JOB 1";"Town 1";"PHONE 1";"COMMENT 1";

"111222334";"Company A";"NAME A ";"FIRSTNAME 4";"JOB 1";"Town 1";"PHONE 1";" MY PERSONAL COMMENT";

"118822333";"Company B";"NAME T ";"FIRSTNAME 1";"JOB 2";"Town 2";"PHONE 65"; "COMMENT 1235";

"111275333";"Company C";"NAME M ";"FIRSTNAME 2";"JOB 7";"Town 1";"PHONE 6";"";

"55222334";"Company Y";"NAME G ";"FIRSTNAME 4";"JOB 52";"Town 1";"PHONE 1";" MY PERSONAL COMMENT";


Thanks,
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]
sharma__r@hotmail.com [sed-users]
2016-01-14 05:22:21 UTC
Permalink
sed -e '
1b
h; s/;/\n/7; s/;/\n/6
/\n"PHONE 1"\n/!{g;b;}
g; s/;/\n/8; s/;/\n/7
/\n""\n/!{g;b;}
s//;"XXXXXXXXXX";/
' yourfile


HTH


---In sed-***@yahoogroups.com, <***@...> wrote :

Hi,

Still again I ask for your help for the example below.

In my file example below, I need to compare the column with the name "PHONE" with the column with the name "COMMENT"

If for a same line the field in the column "PHONE" is equal to "PHONE1" AND the field in column "COMMENT" is blank THEN replace the field blank by "MY PERSONAL COMMENT"
The file below is only for example. The original file, has more columns and more lines.


"id";"Company";"NAME ";"FIRSTNAME";"JOB";"Town";"PHONE";"COMMENT";

"111222333";"Company A";"NAME A ";"FIRSTNAME 1";"JOB 1";"Town 1";"PHONE 1";"COMMENT 1";

"111222334";"Company A";"NAME A ";"FIRSTNAME 4";"JOB 1";"Town 1";"PHONE 1";"";

"118822333";"Company B";"NAME T ";"FIRSTNAME 1";"JOB 2";"Town 2";"PHONE 65"; "COMMENT 1235";

"111275333";"Company C";"NAME M ";"FIRSTNAME 2";"JOB 7";"Town 1";"PHONE 6";"";

"55222334";"Company Y";"NAME G ";"FIRSTNAME 4";"JOB 52";"Town 1";"PHONE 1";"";



Need to obtain the result below.


"id";"Company";"NAME ";"FIRSTNAME";"JOB";"Town";"PHONE";"COMMENT";

"111222333";"Company A";"NAME A ";"FIRSTNAME 1";"JOB 1";"Town 1";"PHONE 1";"COMMENT 1";

"111222334";"Company A";"NAME A ";"FIRSTNAME 4";"JOB 1";"Town 1";"PHONE 1";" MY PERSONAL COMMENT";

"118822333";"Company B";"NAME T ";"FIRSTNAME 1";"JOB 2";"Town 2";"PHONE 65"; "COMMENT 1235";

"111275333";"Company C";"NAME M ";"FIRSTNAME 2";"JOB 7";"Town 1";"PHONE 6";"";

"55222334";"Company Y";"NAME G ";"FIRSTNAME 4";"JOB 52";"Town 1";"PHONE 1";" MY PERSONAL COMMENT";


Thanks,
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]



[Non-text portions of this message have been removed]
MOKRANI Rachid rachid.mokrani@ifpen.fr [sed-users]
2016-01-14 09:17:31 UTC
Permalink
Thanks a lot.

-----Message d'origine-----
De : sed-***@yahoogroups.com [mailto:sed-***@yahoogroups.com]
Envoyé : jeudi 14 janvier 2016 06:22
À : sed-***@yahoogroups.com
Objet : Re: compare column





sed -e '

1b

h; s/;/\n/7; s/;/\n/6

/\n"PHONE 1"\n/!{g;b;}

g; s/;/\n/8; s/;/\n/7

/\n""\n/!{g;b;}

s//;"XXXXXXXXXX";/

' yourfile





HTH





---In sed-***@yahoogroups.com, <***@...> wrote :



Hi,



Still again I ask for your help for the example below.



In my file example below, I need to compare the column with the name "PHONE" with the column with the name "COMMENT"



If for a same line the field in the column "PHONE" is equal to "PHONE1" AND the field in column "COMMENT" is blank THEN replace the field blank by "MY PERSONAL COMMENT"

The file below is only for example. The original file, has more columns and more lines.





"id";"Company";"NAME ";"FIRSTNAME";"JOB";"Town";"PHONE";"COMMENT";



"111222333";"Company A";"NAME A ";"FIRSTNAME 1";"JOB 1";"Town 1";"PHONE 1";"COMMENT 1";



"111222334";"Company A";"NAME A ";"FIRSTNAME 4";"JOB 1";"Town 1";"PHONE 1";"";



"118822333";"Company B";"NAME T ";"FIRSTNAME 1";"JOB 2";"Town 2";"PHONE 65"; "COMMENT 1235";



"111275333";"Company C";"NAME M ";"FIRSTNAME 2";"JOB 7";"Town 1";"PHONE 6";"";



"55222334";"Company Y";"NAME G ";"FIRSTNAME 4";"JOB 52";"Town 1";"PHONE 1";"";







Need to obtain the result below.





"id";"Company";"NAME ";"FIRSTNAME";"JOB";"Town";"PHONE";"COMMENT";



"111222333";"Company A";"NAME A ";"FIRSTNAME 1";"JOB 1";"Town 1";"PHONE 1";"COMMENT 1";



"111222334";"Company A";"NAME A ";"FIRSTNAME 4";"JOB 1";"Town 1";"PHONE 1";" MY PERSONAL COMMENT";



"118822333";"Company B";"NAME T ";"FIRSTNAME 1";"JOB 2";"Town 2";"PHONE 65"; "COMMENT 1235";



"111275333";"Company C";"NAME M ";"FIRSTNAME 2";"JOB 7";"Town 1";"PHONE 6";"";



"55222334";"Company Y";"NAME G ";"FIRSTNAME 4";"JOB 52";"Town 1";"PHONE 1";" MY PERSONAL COMMENT";





Thanks,

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]





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



------------------------------------
Posted by: ***@hotmail.com
------------------------------------

--

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

Yahoo Groups Links



__________________________
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.
__________________________

Loading...