I have dumped the database table data into a flat file and below is how the data looks like : (Kindly copy from below
;metier_code ;
;-------------------------;
(0 rows affected)
;CRDS_Ptf_No; ; ; ; ; ; ; ; ; ; ; ; ; ; ;Status;
;-----------;----------;--------------------------------;-------------------------;----------;--------------------------------;-;-------------------------;-------------------------;---------------;---------------;---------------;-------------------------;-------------------------;-----;------;
; NULL;ABCD ;ABHJARS ; ;ABCD ;ABCD ;Y; ; ; ; ; ; ; ; ;A ;
; 1234;XEU-ANKD ;XEU-AJKD ; ;ABCD ;ABCD ;Y; ; ; ; ; ; ; ; ;A ;
.
.
; 11745;ANJLDMAOKD;AMKDJ AN DJ JAHF AS CPFVH ACCR ;NONE ;AN DJ JAHA;AN DJ JAHA ;Y;NO ANKIO GAP ;YES AMK SCF ; ; ; ; ; ; ;I ;
; 11744;AMKDIONSKH;AMKDJ AN DJ JAHF AS CPFVH MTM ;NONE ;AN DJ JAHA;AN DJ JAHA ;Y;NO ANKIO GAP ;YES AMK SCF ; ; ; ; ; ; ;I ;
(5436 rows affected)
(return status = 0)
Return parameters:
; ;
;-----------;
; 5436;
(1 row affected)
; ; ;
;-------;-----------;
;grepkey; 5436;
(1 row affected)
want to convert the above as below format:
Row should contain the seq no (Prefixed) Need to remove columns names and the blank spaces present in the original file at begining and ending.
BELOW IS THE FORMAT OF DATA THAT I AM GETTING BY USING THE SUGGESTED CODE:
awk -F ';' '/^;-----------;/ {start=1;next;}; start==0 {next;}; {gsub(" +",""); print NR "" $0;}' temp_file > test
FORMAT after executing above script :
7;NULL;ABCD;ABHJARS;;ABCD;ABCD;Y;;;;;;;;;A;
8;NULL;XEU-ANKD;XEU-AJKD;;ABCD;ABCD;Y;;;;;;;;;A;
.
.
5443;11744;AMKDIONSKH;AMKDJ AN DJ JAHF AS CPFVH MTM;;QWERDF;QWERDF;Y;;;;;;;;;A;
5444
5445(5436rowsaffected)
5446(returnstatus=0)
5447
5448Returnparameters:
5449
5450;;
5452;5436;
5453
5454
5455(1rowaffected)
5456;;;
5457;-------;-----------;
5458;grepkey;5436;
5459
5460(1rowaffected)
Above : the prefix row number is not coming in sequence(Incrementing by using the preceeding lines that is not the actual data). Initial file was containing additional info in flat file like column name @ begining , at the end of file few additional details that i wanted like count of records etc
I want the data in below format (Which shall have prefix row number and shall include only rows of table , not the additional preceeding and exceeding data)
1;NULL;ABCD;ABHJARS;;ABCD;ABCD;Y;;;;;;;;;A;
2;NULL;XEU-ANKD;XEU-AJKD;;ABCD;ABCD;Y;;;;;;;;;A;
3;NULL;SWAPOLEIL;SWAPOLEIL;;QWERDF;QWERDF;Y;;;;;;;;;A;
.
.
5436;11744;AMKDIONSKH;AMKDJ AN DJ JAHF AS CPFVH MTM;;QWERDF;QWERDF;Y;;;;;;;;;A;
5436 - is the number of rows present in the table from where i am fetching the data.
Thanks in advance!
(Tried the other suggested solutions as well . However, dint got the desired result)