Hi,
I am having source \(Oracle\) as given below.
SourceOBJECT_NAMESUBOBJECT_NAMEOBJECT_IDDATA_OBJECT_IDOBJECT_TYPECREATEDLAST_DDL_TIMESTAMPSTATUSTGSTEST 336559336559TABLE4/15/2009 10:374/15/2009 10:372009-04-15:10:37:57VALIDNNNUNIX 336559336559TABLE4/15/2009 10:374/15/2009 10:372009-04-15:10:37:57VALIDNNNWINDOWS 336559336559TABLE4/15/2009 10:374/15/2009 10:372009-04-15:10:37:57VALIDNNNINFORM 336559336559TABLE4/15/2009 10:374/15/2009 10:372009-04-15:10:37:57VALIDNNN
While i am using the below functions, as the 2nd column SUBOBJECT_NAME is having NULL values, the 3rd column values are moving into 2nd column and so on.
Commands:
perl -pne 's/\s+([^\s+])/,\1/g' out.txt
awk '$1=$1' OFS=\, file
awk -F, 'NF==6{$0=gensub ("([0-9]+, [[:alpha:]]+),","\\1",1);$0=gensub (", ([[:alpha:]]+, [0-9]+$)"," \\1",1)}1' file
Target data:
OBJECT_NAME,SUBOBJECT_NAME,OBJECT_ID,DATA_OBJECT_ID,OBJECT_TYPE,CREATED,LAST_DDL_,TIMESTAMP,STATUS,T,G,S
TEST,336559,336559,TABLE,15-Apr-09,15-Apr-09,2009-04-15:10:37:57,VALID,N,N,N,
UNIX,336559,336559,TABLE,15-Apr-09,15-Apr-09,2009-04-15:10:37:57,VALID,N,N,N,
EBILITE,336559,336559,TABLE,15-Apr-09,15-Apr-09,2009-04-15:10:37:57,VALID,N,N,N,
EBILITE,MIGRATION,336559,336559,TABLE,15-Apr-09,15-Apr-09,2009-04-15:10:37:57,VALID,N,N,N
My Requirement: I want the null values to be present in the file and should be separated by comma.
Thanks in advance for your replies.