Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiline awk to generate csv 1

Status
Not open for further replies.

dsawk

Programmer
Oct 6, 2005
4
DE
hello,
i have the following logfile. i want to extract some fields so that i get a csv that i get a csv with following structure:

Type;Table;Space;Field

for example

Insert;BSHOI.R002300T;R002900D.R002901S;INSTSCHL

I`ve tried FS and RS functions, but it doesn`t work. Can you help me? Is awk the right language?

Can you Help me?

Thanks.

Logfile:

--------------------------------------------------------------------------------
0From: 2002-09-02 06.00.00.000000
To: 2002-09-02 17.00.00.000000
0--------------------------------------------------------------------------------
Report Information:
0Work ID : #23237A.R002300T Run Number: 1 Subsystem: DB2P
Description: #23237C 2002-09-03 11.00.19
--------------------------------------------------------------------------------
0Authid: #041657
0 URID : x'069868F61443' Date : 2002-09-02 Conn Type: MA
Status : Committed Time : 07.05.46.295 Conn ID : CTL
Plan Name: A429A Auth ID: #041657 Corr ID : 0010A429A
0 ----------------------------------------------------------------------------
Type: Insert At: x'069868F61CB1' Time: 2002-09-02 07.05.46.357
Status: Committed
0 Table Name: BSHOI.R002300T DBID.OBID: (285.3)
Space Name: R002900D.R002901S DBID.PSID: (285.2)
0 Field Data: INSTSCHL KUNDENNR********** PROVKTONR* PRODART ANZBAE***
New: 900 000000153910840101 0035409800 001 15.000
0 ANZNAEW** ANZNAEZ** FILMDAT*** BILDNR ANZRATGES
New: 0.000 0.000 2002-08-29 05492 0
0 ANZRATIERT MKMABRECH MKMPVERD MKMSTORNO STRUKERMDAT
New: 0 J N 2002-09-02
0 ANLDAT**** ANLSBM AENDDAT*** AENDSBM UNTERKONTO
New: 2002-09-02 MR6522 *NULL* *NULL* 0001
0 KDNAME************************
New: *NULL*
0 BEMERKUNG***************************************************
New: *NULL*
0 Totals For: URID: x'069868F61443'
Ins: 1 Del : 0 Upd : 0
Tot: 1 Del/RI: 0 Upd/RI: 0
0 URID : x'0698690947CA' Date : 2002-09-02 Conn Type: MA
Status : Committed Time : 07.07.42.365 Conn ID : CTL
Plan Name: A429A Auth ID: #041657 Corr ID : 0022A429A
0 ----------------------------------------------------------------------------
Type: Insert At: x'069869094B3B' Time: 2002-09-02 07.07.42.369
Status: Committed
0 Table Name: BSHOI.R002300T DBID.OBID: (285.3)
Space Name: R002900D.R002901S DBID.PSID: (285.2)
0 Field Data: INSTSCHL KUNDENNR********** PROVKTONR* PRODART ANZBAE***
New: 900 000000153910920101 0035409800 001 10.000
1Date: 2002-09-03 LOG MASTER FOR DB2 - V2.3.00 Page: 2
Time: 11.19.28 Copyright BMC Software, Inc. 1995-2002
0 Detail Report, By Authid, Urid
--------------------------------------------------------------------------------
0 ANZNAEW** ANZNAEZ** FILMDAT*** BILDNR ANZRATGES
New: 0.000 0.000 2002-08-29 05494 0
0 ANZRATIERT MKMABRECH MKMPVERD MKMSTORNO STRUKERMDAT
New: 0 J N 2002-09-02
0 ANLDAT**** ANLSBM AENDDAT*** AENDSBM UNTERKONTO
New: 2002-09-02 MR6522 *NULL* *NULL* 0001
0 KDNAME************************
New: *NULL*
0 BEMERKUNG***************************************************
New: *NULL*
0 Totals For: URID: x'0698690947CA'
Ins: 1 Del : 0 Upd : 0
Tot: 1 Del/RI: 0 Upd/RI: 0
0 URID : x'0698696338E3' Date : 2002-09-02 Conn Type: MA
Status : Committed Time : 07.11.48.814 Conn ID : CTL
Plan Name: A429A Auth ID: #041657 Corr ID : 0032A429A
0 ----------------------------------------------------------------------------
Type: Insert At: x'069869633C58' Time: 2002-09-02 07.11.48.818
Status: Committed
0 Table Name: BSHOI.R002300T DBID.OBID: (285.3)
Space Name: R002900D.R002901S DBID.PSID: (285.2)
0 Field Data: INSTSCHL KUNDENNR********** PROVKTONR* PRODART ANZBAE***
New: 900 000000153910950101 0035409800 001 10.000
0 ANZNAEW** ANZNAEZ** FILMDAT*** BILDNR ANZRATGES
New: 0.000 0.000 2002-08-29 05495 0
0 ANZRATIERT MKMABRECH MKMPVERD MKMSTORNO STRUKERMDAT
New: 0 J N 2002-09-02
0 ANLDAT**** ANLSBM AENDDAT*** AENDSBM UNTERKONTO
New: 2002-09-02 MR6522 *NULL* *NULL* 0001
0 KDNAME************************
New: *NULL*
0 BEMERKUNG***************************************************
New: *NULL*
0 Totals For: URID: x'0698696338E3'
Ins: 1 Del : 0 Upd : 0
Tot: 1 Del/RI: 0 Upd/RI: 0
1Date: 2002-09-03 LOG MASTER FOR DB2 - V2.3.00 Page: 3
Time: 11.19.28 Copyright BMC Software, Inc. 1995-2002
0 Detail Report, By Authid, Urid
--------------------------------------------------------------------------------
0 URID : x'069869EEA36E' Date : 2002-09-02 Conn Type: MA
Status : Committed Time : 07.13.00.628 Conn ID : CTL
Plan Name: A429A Auth ID: #041657 Corr ID : 0010A429A
0 ----------------------------------------------------------------------------
Type: Insert At: x'069869EEBE06' Time: 2002-09-02 07.13.00.647
Status: Committed
0 Table Name: BSHOI.R002300T DBID.OBID: (285.3)
Space Name: R002900D.R002901S DBID.PSID: (285.2)
0 Field Data: INSTSCHL KUNDENNR********** PROVKTONR* PRODART ANZBAE***
New: 900 000000153911150101 0035409800 001 10.000
0 ANZNAEW** ANZNAEZ** FILMDAT*** BILDNR ANZRATGES
New: 0.000 0.000 2002-08-29 05496 0
0 ANZRATIERT MKMABRECH MKMPVERD MKMSTORNO STRUKERMDAT
New: 0 J N 2002-09-02
0 ANLDAT**** ANLSBM AENDDAT*** AENDSBM UNTERKONTO
New: 2002-09-02 MR6522 *NULL* *NULL* 0001
0 KDNAME************************
New: *NULL*
0 BEMERKUNG***************************************************
New: *NULL*
0 Totals For: URID: x'069869EEA36E'
Ins: 1 Del : 0 Upd : 0
Tot: 1 Del/RI: 0 Upd/RI: 0
0 URID : x'06986B477C4D' Date : 2002-09-02 Conn Type: MA
Status : Committed Time : 07.14.19.110 Conn ID : CTL
Plan Name: A429A Auth ID: #041657 Corr ID : 0022A429A
0 ----------------------------------------------------------------------------
 
Something like this ?

BEGIN{OFS=";"}
/Type:/{p=$0;sub(/.*Type: +/,"",p);sub(/ .*/,"",p)}
/Table Name:/{t=$0;sub(/.*Table Name: +/,"",t);sub(/ .*/,"",t)}
/Space Name:/{s=$0;sub(/.*Space Name: +/,"",s);sub(/ .*/,"",s)}
/Field Data:/{f=$0;sub(/.*Field Data: +/,"",f);sub(/ .*/,"",f);print p,t,s,f}

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks, that`s the solution i looked for. Maybee i have to expand this version in subject to the type. Can you help me again, if i know if there are additional requirements?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top