Hello Everyone,
This is my question. I have two files and based on these files, I need to create a third file as mentioned below.
FILE1:
------
field1,field2,field3,field4,field5,field6,field7,field8,field9,field10,field11,field12,field13,field14
AA AAA Aaaaaaaaa,11111111,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111
AA AAA Aaaaaaaaa,11111111,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111
AA AAA Abbbbbbb,11111111,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111
BB BBB Axxxxxxxx,22222222,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111
BB BBB Axxxxxxxx,22222222,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111
BB BBB dddddddd,22222222,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111
I need to take the second column from this file_1 (which is a comma delimited file), here the values are : 11111111 and 22222222.
FILE2:
------
Here, I need to consider the last_column which is single character which is a middle initial.
11111111,last_name,first_name,D
22222222,last_name,first_name,
Finally, I need to add the new column to the file1 as field15 which consists of the values as "D and comma (D,)" for the records 11111111 and "null as ,," for the records 22222222 since this record
does not have any value in the last_column.
The output file should be like this:
------------------------------------
field1,field2,field3,field4,,field5,field6,field7,field8,field9,field10,field11,field12,field13,field14,field15
AA AAA Aaaaaaaaa,11111111,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111,D,
AA AAA Aaaaaaaaa,11111111,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111,D,
AA AAA Abbbbbbb,11111111,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111,D,
BB BBB Axxxxxxxx,22222222,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111,,
BB BBB Axxxxxxxx,22222222,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111,,
BB BBB dddddddd,22222222,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111,,
Can this be done with awk ? and redireted to the outputfile ?
Thanks again, for all the help in advance and I appreciate all the help and thanskf or this website too.
Regards,
Bhanu
This is my question. I have two files and based on these files, I need to create a third file as mentioned below.
FILE1:
------
field1,field2,field3,field4,field5,field6,field7,field8,field9,field10,field11,field12,field13,field14
AA AAA Aaaaaaaaa,11111111,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111
AA AAA Aaaaaaaaa,11111111,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111
AA AAA Abbbbbbb,11111111,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111
BB BBB Axxxxxxxx,22222222,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111
BB BBB Axxxxxxxx,22222222,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111
BB BBB dddddddd,22222222,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111
I need to take the second column from this file_1 (which is a comma delimited file), here the values are : 11111111 and 22222222.
FILE2:
------
Here, I need to consider the last_column which is single character which is a middle initial.
11111111,last_name,first_name,D
22222222,last_name,first_name,
Finally, I need to add the new column to the file1 as field15 which consists of the values as "D and comma (D,)" for the records 11111111 and "null as ,," for the records 22222222 since this record
does not have any value in the last_column.
The output file should be like this:
------------------------------------
field1,field2,field3,field4,,field5,field6,field7,field8,field9,field10,field11,field12,field13,field14,field15
AA AAA Aaaaaaaaa,11111111,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111,D,
AA AAA Aaaaaaaaa,11111111,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111,D,
AA AAA Abbbbbbb,11111111,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111,D,
BB BBB Axxxxxxxx,22222222,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111,,
BB BBB Axxxxxxxx,22222222,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111,,
BB BBB dddddddd,22222222,DDDDDDDDDD,last_name,first_name,F,19380101,EEE,254,20070116,20070116,,PHYSICIAN,H1111,,
Can this be done with awk ? and redireted to the outputfile ?
Thanks again, for all the help in advance and I appreciate all the help and thanskf or this website too.
Regards,
Bhanu