Re: sed/awk - columns to rows for a data series



Banzai wrote:

I have a data series, thus:

========== Tue May 8 00:24:59 BST 2007
ACTIVE SMP 2
ACTIVE SYS 1
ACTIVE 15
INACTIVE DBSNMP 1
INACTIVE JSECURE 5
INACTIVE SMP 15
SNIPED JSECURE 14
SNIPED SMP 7
========== Tue May 8 00:30:00 BST 2007
ACTIVE SMP 3
ACTIVE SYS 1
ACTIVE 15
INACTIVE DBSNMP 1
INACTIVE JSECURE 7
INACTIVE SMP 11
SNIPED JSECURE 1
SNIPED SMP 7
========== Tue May 8 00:35:00 BST 2007
ACTIVE SMP 2
ACTIVE SYS 2
ACTIVE 15
INACTIVE DBSNMP 1
INACTIVE JSECURE 8
INACTIVE SMP 11
SNIPED JSECURE 3
SNIPED SMP 5

Can somebody help me to parse the file so that I have the output like:


00:24:59 2 1 15 1 5 15 14 7
00:30:00 3 1 15 1 7 11 1 7
00:35:00 2 2 15 1 8 11 3 5


Formatting /spacing not important as long as the sense is correct (it can be space
or tab or csv delimitted) - i need to sunsequently import the series into excel.

perl -lne'
BEGIN {
$/ = "=" x 10;
$, = " "; # change to "\t" for tab or "," for comma
}
s/\d+$//m; # remove the year from the date on first line
print /(\d+:\d+:\d+)/, /\d+$/mg;
'



John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
.



Relevant Pages

  • Re: sed/awk - columns to rows for a data series
    ... Banzai wrote: ... I have a data series, ... Can somebody help me to parse the file so that I have the output like: ... Formatting /spacing not important as long as the sense is correct - i need to sunsequently import the series into excel. ...
    (comp.unix.shell)
  • Re: sed/awk - columns to rows for a data series
    ... I have a data series, ... Can somebody help me to parse the file so that I have the output like: ... Formatting /spacing not important as long as the sense is correct - i need to sunsequently import the series into excel. ... a.join}' thefile ...
    (comp.unix.shell)
  • Re: sed/awk - columns to rows for a data series
    ... I have a data series, ... Can somebody help me to parse the file so that I have the output like: ... Formatting /spacing not important as long as the sense is correct (it can ... a.join}' thefile ...
    (comp.unix.shell)
  • sed/awk - columns to rows for a data series
    ... I have a data series, ... Can somebody help me to parse the file so that I have the output like: ... Formatting /spacing not important as long as the sense is correct - i need to sunsequently import the series into excel. ...
    (comp.unix.shell)
  • RE: Chart problem
    ... "Igor" wrote: ... In each period in the X-Axis I need to have 2 ... I have tried to solve this by formatting the data series, ...
    (microsoft.public.excel.misc)