Input:
Component Part # Serial Description Date Time Vend
Location
--------- ------ ------ ----------- ---- ---- ----
--------
SSC0 501-5407-14-59 038298 System Cont 09/22 05:21:53 012c
Sriracha,
roller 2004 GMT+05:00
Chonburi,
Thailand
ID0 501-4406-07-50 904882 Sun Fire 48 06/30 02:35:54 03c1
Juarez Me
00 Centerpl 2004 GMT+05:00
xico
ane
PS0 300-1460-03-52 C13906 Power Suppl 08/14 23:45:01 031a
Matamoros
y (A153, F4 2002 GMT
+05:00 , Tamps,
800)
Mexico
PS1 300-1460-04-50 W17035 Power Suppl 03/22 16:05:41 026d
FDK CHINA
y (A153, F4 2004 GMT+05:00
800)
FT0 540-4345-01-52 LK0040 Fan Tray (F 11/24 13:37:14 021c
Lisburn
4800, Botto 2004 GMT+05:00
m I/O)
FT1 540-4344-02-52 LJ00ME Fan Tray (F 10/20 14:16:04 021c
Sanmina-S
4800, Top I 2004 GMT+05:00
CI Lisbur
/O)
n
FT2 540-3586-01-52 LG00M7 Fan Tray (F 10/20 14:51:19 021c
Sanmina-S
4800, CPU) 2004 GMT+05:00
CI, Lisb
urn
RP0 501-6418-05-51 021975 Repeater Bo 08/23 08:52:31 012c
Sriracha,
ard 2004 GMT+05:00
Chonburi,
Thailand
RP2 501-6418-05-51 022243 Repeater Bo 08/30 21:23:02 012c
Sriracha,
ard 2004 GMT+05:00
Chonburi,
Thailand
/N0/SB0 501-7539-02-50 A00386 CPU Board V 01/14 18:18:02 0301
Penang, M
2 2007 GMT+05:00
alaysia
/N0/SB2 501-6178-03-51 A38545 CPU Board V 01/28 02:35:05 0301
Penang, M
2 2004 GMT+05:00
alaysia
/N0/SB0/P2/B0/D0 501-5030-03-50 329361 512 MB NG S 10/28 18:59:36 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB0/P2/B0/D1 501-5030-03-50 334926 512 MB NG S 10/28 19:33:12 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB0/P2/B0/D2 501-5030-03-50 334931 512 MB NG S 10/28 19:33:12 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB0/P2/B0/D3 501-5030-03-50 329682 512 MB NG S 10/28 22:55:48 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB0/P3/B0/D0 501-5030-03-50 270045 512 MB NG S 10/29 19:18:49 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB0/P3/B0/D1 501-5030-03-50 270871 512 MB NG S 10/29 20:02:57 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB0/P3/B0/D2 501-5030-03-50 270014 512 MB NG S 10/29 19:27:57 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB0/P3/B0/D3 501-5030-03-50 270022 512 MB NG S 10/29 19:27:57 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB2/P2/B0/D0 501-5030-03-50 328988 512 MB NG S 10/28 17:20:46 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB2/P2/B0/D1 501-5030-03-50 334841 512 MB NG S 10/28 16:53:11 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB2/P2/B0/D2 501-5030-03-50 334875 512 MB NG S 10/28 16:58:57 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB2/P2/B0/D3 501-5030-03-50 329489 512 MB NG S 10/28 17:15:35 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB2/P3/B0/D0 501-5030-03-50 328956 512 MB NG S 10/28 16:34:08 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB2/P3/B0/D1 501-5030-03-50 334991 512 MB NG S 10/28 16:58:57 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB2/P3/B0/D2 501-5030-03-50 270196 512 MB NG S 10/29 17:54:51 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB2/P3/B0/D3 501-5030-03-50 270181 512 MB NG S 10/29 17:54:51 00ce
ONYANG,KO
DRAM DIMM 2004 GMT+05:00
REA
/N0/SB0/P2/E0 371-1594-01-01 0D2540 4MB Ecache 12/13 10:02:37 00ce
Celestica
Module 2006 GMT
+05:00 Toronto,
Canada
/N0/SB0/P2/E1 371-1594-01-01 0D2HV9 4MB Ecache 12/13 10:04:08 00ce
Celestica
Module 2006 GMT
+05:00 Toronto,
Canada
/N0/SB0/P3/E0 371-1594-01-01 0D2ZM1 4MB Ecache 12/13 10:56:28 00ce
Celestica
Module 2006 GMT
+05:00 Toronto,
Canada
/N0/SB0/P3/E1 371-1594-01-01 0D2ZEH 4MB Ecache 12/13 10:55:14 00ce
Celestica
Module 2006 GMT
+05:00 Toronto,
Canada
/N0/SB2/P2/E0 370-4128-03-50 1B9D2K 4MB Ecache 01/08 02:38:47 00ce
Celestica
Module 2004 GMT
+05:00 Toronto,
Canada
/N0/SB2/P2/E1 370-4128-03-50 1B91GM 4MB Ecache 01/08 02:38:40 00ce
Celestica
Module 2004 GMT
+05:00 Toronto,
Canada
/N0/SB2/P3/E0 370-4128-03-50 1B91GN 4MB Ecache 01/08 02:38:43 00ce
Celestica
Module 2004 GMT
+05:00 Toronto,
Canada
/N0/SB2/P3/E1 370-4128-03-50 1B8XUX 4MB Ecache 01/08 02:38:45 00ce
Celestica
Module 2004 GMT
+05:00 Toronto,
Canada
/N0/IB6 501-4404-13-51 054123 PCI I/O Ass 02/22 09:32:47 012c
Celestica
embly 2004 GMT
+05:00 ,Toronto,
Ontario
/N0/IB8 501-4404-13-51 054219 PCI I/O Ass 02/25 08:42:03 012c
Celestica
embly 2004 GMT
+05:00 ,Toronto,
Ontario
above output is a multilined columns and a maximum of 3 lines are
there .
Output.
I need to them all in a single line with correct column values
appended. like last line will be like.
/N0/IB8 501-4404-13-51 054219 PCI I/O Assembly 02/25 2004 08:42:03 GMT
+05:00 012c Celestica,Toronto,Ontario
This is all one line instead of multiple lines.
Regards,
BB.
> /N0/IB6 501-4404-13-51 054123 PCI I/O Ass 02/22 09:32:47 012c
> Celestica
> embly 2004 GMT
> +05:00 ,Toronto,
>
> Ontario
> /N0/IB8 *-4404-13-51 054219 PCI I/O Ass 02/25 08:42:03 012c
> Celestica
> embly 2004 GMT
> +05:00 ,Toronto,
>
> Ontario
>
> above output is a multilined columns and a maximum of 3 lines are there
> .
>
> Output.
>
> I need to them all in a single line with correct column values appended.
> like last line will be like.
>
> /N0/IB8 501-4404-13-51 054219 PCI I/O Assembly 02/25 2004 08:42:03 GMT
> +05:00 012c Celestica,Toronto,Ontario
>
> This is all one line instead of multiple lines.
Interesting...
As from here it looks much worse than just 'one instead of mult'
would you please post a shorter sample data with shorter fields
that wouldn't wrap when posted!
(what I see here is b0tched stuff like:
-----------
/N0/IB8 'some num refs' 'start of label' 'date'
'part of address'
[blanks] 'end of label' 'start of time'
'end of time' , 'start of city/state'
<blank line>
'end of city/state'
-----------
)
and if your data really is what it looks here you may need a boar
a goat and several chickens sacrified in front of the printer ,-)
> Moody <nasir....@gmail.com> writes:
>
>> Input:
>
> <I'll snip most of it>
ditto ;-)
>> /N0/IB8 501-4404-13-51 054219 PCI I/O Ass 02/25 08:42:03 012c
>> Celestica
>> embly 2004 GMT
>> +05:00 ,Toronto,
...
>> This is all one line instead of multiple lines.
>
> Your post has had its lines broken so it is very hard to tell exactly
> what it going on, but I think you'll need something like a Perl script
> to do this.
was that the reason why you broke the multipost and threw the cl.awk out?~>
Here my guess about how the original data might look like: multi-line
records separated by an empty line, each record has 8 fix-width columns
SSC0 501-5407-14-59 038298 System Cont 09/22 05:21:53 012c
Sriracha,
roller 2004 GMT+05:00
Chonburi,
Thailand
ID0 501-4406-07-50 904882 Sun Fire 48 06/30 02:35:54 03c1
Juarez Me
00 Centerpl 2004 GMT+05:00 xico
ane
/N0/IB8 501-4404-13-51 054219 PCI I/O Ass 02/25 08:42:03 012c
Celestica
embly 2004 GMT+05:00
,Toronto,
Ontario
Here a script, which uses several gawk extensions:
$ cat moody.awk
BEGIN { FIELDWIDTHS = "17 15 7 12 6 9 5 9" }
NF {
for (i = 1; i <= NF; i++) {
a[i] = a[i] s[i] trim($i)
s[i] = i == 5 || i == 6 ? " " : ""
}
next
}
{
for (i = 1; i <= length(a); i++)
printf "|%s", trim(a[i])
print "|"
delete a
delete s
}
function trim(str) {
sub(/^[[:space:]]+/, "", str)
if (str) sub(/[[:space:]]+$/, "", str)
return str
}
$ gawk -f moody.awk testdata
|SSC0|501-5407-14-59|038298|System Controller|09/22 2004|05:21:53
GMT+05:00|012c|Sriracha,Chonburi,Thailand|
|ID0|501-4406-07-50|904882|Sun Fire 4800 Centerplane|06/30 2004|02:35:54
GMT+05:00|03c1|Juarez Mexico|
That input still wraps on my screen so I still can't tell for sure what it's
supposed to be and I couldn't get the script to produce that output and couldn't
be bothered to debug the script or input file, so let';s try getting some
representative input that fits on a screen. Keeping just the interesting fields,
I THINK it's supposed to be something like this:
#######################################
Component Description Time Location
--------- ----------- ---- --------
SSC0 System Cont 05:21:53 Sriracha,
roller GMT+05:00Chonburi,
Thailand
ID0 Sun Fire 48 02:35:54 Juarez Me
00 Centerpl GMT+05:00xico
ane
/N0/IB8 PCI I/O Ass 08:42:03 Celestica
embly GMT+05:00,Toronto,
Ontario
########################################
with desired output:
########################################
SSC0|System Controller|09/22 2004|05:21:53 GMT+05:00|Sriracha,Chonburi,Thailand
ID0|Sun Fire 4800 Centerplane|02:35:54 GMT+05:00|Juarez Mexico
/N0/IB8|PCI I/O Assembly|08:42:03 GMT+05:00|Celestica,Toronto,Ontario
########################################
Right?
Ed.
Should be:
########################################
SSC0|System Controller|05:21:53 GMT+05:00|Sriracha,Chonburi,Thailand
ID0|Sun Fire 4800 Centerplane|02:35:54 GMT+05:00|Juarez Mexico
/N0/IB8|PCI I/O Assembly|08:42:03 GMT+05:00|Celestica,Toronto,Ontario
########################################
sigh...
> Right?
>
> Ed.
Right. Here the slightly modified script that produces the above output.
I guess you can make it with substantially less than code. I also
cheated somewhat as the script expects an empty line at the end of the
data file
Hermann
BEGIN { FIELDWIDTHS = "10 12 9 9" }
NR < 3 { next }
NF {
for (i = 1; i <= NF; i++) {
a[i] = a[i] s[i] trim($i)
s[i] = i == 3 ? " " : ""
}
next
}
{
n = length(a)
for (i = 1; i <= n; i++) {
printf "%s%s", trim(a[i]),
i == n ? "\n" : "|"
> Mon, 23 Nov 2009 14:09:00 +0000, Ben Bacarisse did cat :
<snip>
>> Your post has had its lines broken so it is very hard to tell exactly
>> what it going on, but I think you'll need something like a Perl script
>> to do this.
>
> was that the reason why you broke the multipost and threw the cl.awk out?~>
'twas a cross-post surely?
It was mainly an error. I was going to post some Perl, but not
knowing comp.lang.awk's policy on such things I cut the group. But
then something came up and I had no time for code but did not restore
the groups.
--
Ben.