Hi everyone,
Maybe somebody could help me with this.
I have a text file showing in 2 columns registers of services used by customers in a comercial place.
The register for the use of any particular service begins with "EVENT" in column 1.
I would like to transpose the info for each block in one line. I mean, the different
words in column 1 will appear only once like a header, and the data in column 2
will appear below of its respective column in 1 line only.
Source file. (Not all blocks have the same registers in column 1, some have more than others)
EVENT
INTERNET CONNECTION
Date 11/01/2009
Initial hour 07:30
Number of users 27
Average of use 32 min
Final hour 19:00
EVENT
LOCAL CALL
Date 11/01/2009
Initial hour 07:42
Number of users 15
Average of use 7 min
Final hour 16:11
EVENT
INTERNATIONAL CALL
Date 11/01/2009
Initial hour 09:14
Number of users 21
Average of use 5 min
Final hour 16:17
EVENT
PRINTER USE
Date 12/01/2009
Initial hour 07:30
Number of users 23
Average of pages printed 17
Final hour 19:00
I would like to tabulate it as follow
EVENT Date Initial hour Number of users Average of use Average of pages printed Final hour
INTERNET CONNECTION 11/01/2009 07:30 27 32 min 19:00
LOCAL CALL 11/01/2009 07:42 15 7 min 16:11
INTERNATIONAL CALL 11/01/2009 09:14 21 5 min 16:17
PRINTER USE 12/01/2009 07:30 23 17 19:00
So far I know that If I use:
awk '/INTERNET CONNECTION/ { getline; print $2}' Input_1.txt
awk '/LOCAL CALL/ { getline; print $2}' Input_1.txt
awk '/INTERNATIONAL CALL/ { getline; print $2}' Input_1.txt
awk '/PRINTER USE/ { getline; print $2}' Input_1.txt
the result is the date (in column 2) for each register
11/01/2009
11/01/2009
11/01/2009
12/01/2009
But how can I follow to get want I want (the other columns below the respective header).
Thanks in advance for any help.
Best regards.