Hi All,
Hope you are doing Great!!!.
Today i have came up with a problem to say exactly it was for performance improvement.
I have written code in perl as a solution for this to cut in specific range, but it is taking time to run for files thousands of lines so i am expecting
a sed command kind of thing to make it run quickly.
input format:
--> TP ID: TEST TP XLATE KEY: ANSIXX99 AL: D
INT ID: TESTREFORMAT XLATE TABLE: X820XR99
DOC ID: 820 DIR: I STD: ANSI COM: X VERS: NONCTX STAT: P
--> TP ID: TEST TP XLATE KEY: ANSIXX41 AL: D
INT ID: TESTREFORMAT XLATE TABLE: X820XR99
DOC ID: 820 DIR: I STD: ANSI COM: X VERS: 004010 STAT: P
--> TP ID: TEST TP XLATE KEY: XXXXXXXX AL: D
INT ID: TESTREFORMAT XLATE TABLE: XXXXXXXX
DOC ID: 820 DIR: I STD: ANSI COM: X VERS: 004010 STAT: T
output format required:
TEST TP,ANSIXX99,D,TESTREFORMAT,X820XR99,820,I,ANSI,X,NONCTX,P
TEST TP,ANSIXX41,D,TESTREFORMAT,X820XR99,820,I,ANSI,X,004010,P
TEST TP,XXXXXXXX,D,TESTREFORMAT,XXXXXXXX,820,I,ANSI,X,004010,T
I have a file with input format given as example in above.
Rules for input format:
- The "--> TP ID:" will repeat for every three lines.
All the values after ":" were variable in length with in length given to it but all the values before ":" was fixed in length.
So our motivation was to make the values after ":" to be like in output format with comma separated value.
I am using AIX V6.0 OS. SED command as solution will be a preferable .
Thanks.
---------- Post updated at 11:03 PM ---------- Previous update was at 11:01 PM ----------
I have pasted actual data but i could see a empty line in between every 3 lines but in actual data there will not be any empty lines in input file.