Re: Sequentielle Liste in Tabelle verwandeln
Hallo Andre!
Andre Tann schrieb am Freitag, den 30. Oktober 2009:
> Heinz Diehl, Freitag 30 Oktober 2009:
> > On 30.10.2009, Andre Tann wrote:
> > > Das will ich umwandeln in eine Tabelle mit einem Datensatz pro
> > > Zeile, und eben sieben Spalten.
> >
> > Wie soll das genau aussehen?
>
> Vereinfacht:
>
> Name Str. Ort Tel Fax Mail
> ============================================
> Name1 Str1 Ort1 Fax1
> Name2 Str2 Ort2 Mail2
> Name3 Str3 Ort3 Tel3 Fax3 Mail3
Perl hatten wir ja schon. Hier die awk Version:
#v+
#!/usr/bin/awk -f
BEGIN {
printf("%-10s\t%-10s\t%-10s\t%-10s\t%-10s\t%-10s\t%-10s\n","Name","Str.","Ort","Tel","Fax","Mail","Internet");
printf("==========================================================================================\n");
}
/./ {a[$1] = $2; }
!/./ {
printf("%-10.10s\t%-10.10s\t%-10.10s\t%-10.10s\t%-10.10s\t%-10.10s\t%-10.10s\n", a["Name"], a["Straße"], a["PLZ"], a["Tel:"], a["Fax:"], a["E-Mail:"], a["Internet:"]);
delete(a);
}
~$
#v-
Grüße
Christian
--
• If you need more than 3 levels of indentation, you're screwed anyway, and
should fix your program.
Linus Torvalds: Linux 1.3.53 CodingStyle documentation.
Reply to: