--------------------------------Linux Guide---------------------------------- by Ingo Blechschmidt (c) 2002 ----------------------------------------------------------------------------- ------------------------- Etiketten drucken ------------------------- Die Oct 23 10:17:28 MEST 2001 ------------------------- Etiketten drucken Drucken etiketten ----------------------------------------------------------------------------- etiketten.pl kann aus CSV-Daten druckerfreundliche Etiketten machen. Ein bisschen Handarbeit wird aber trotzdem benötigt... ----------------------------------------------------------------------------- Mein Skript etiketten.pl erzeugt aus einer CSV-Datei wie die folgende die weiter unten zu sehende Ausgabe: --------CODE--------: daten.csv Nachname;Vorname;Straße;PLZ;Ort Müller;Peter;Meierstr. 7;12345;Mayerstadt Schmidt;Franz;Schmidtweg 2;67891;Schmidten A;B;C;D;E F;G;H;I;J K;L;M;N;O P;Q;R;S;T --------/CODE-------- --------CODE--------: cat daten.csv | ./etiketten.pl --------/CODE-------- Peter~Müller~~~~~~~~~~~~~~Franz~Schmidt~~~~~~~~~~~~~B~A$ Meierstr.~7~~~~~~~~~~~~~~~Schmidtweg~2~~~~~~~~~~~~~~C$ $ 12345~Mayerstadt~~~~~~~~~~67891~Schmidten~~~~~~~~~~~D~E$ $ $ $ $ $ G~F~~~~~~~~~~~~~~~~~~~~~~~L~K~~~~~~~~~~~~~~~~~~~~~~~Q~P$ H~~~~~~~~~~~~~~~~~~~~~~~~~M~~~~~~~~~~~~~~~~~~~~~~~~~R$ $ I~J~~~~~~~~~~~~~~~~~~~~~~~N~O~~~~~~~~~~~~~~~~~~~~~~~S~T$ $ $ $ $ --------/CODE-------- Damit man die Anordnung besser versteht, wurden alle Leerzeichen durch ~ und alle Zeilenenden durch $ ersetzt. Das Skript, siehe <"down/etiketten.pl">Download: --------CODE--------: etiketten.pl #!/usr/bin/perl # etiketten.pl - Formats CSV to printer-friendly etticets (German: Etiketten). # Copyright (C) Die Okt 23 09:57:42 MEST 2001 - now by Ingo Blechschmidt. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # Ingo Blechschmidt # Arberstraße 5 # 86179 Augsburg # E-Mail: iblech@web.de, http://www.way.to/uselinux/ # Tel.: +49 / 821 882955 # # # The reason why no `-w' or `use warnings' is used is, that the script reads in # 3-line-steps the input CSV file (via STDIN). There would be many warnings by # the Perl interpreter. $HEADER = 1; # If set to 0 the first line of the input is NOT # ignored. $FAMNAME = 0; # Column number of the Family Name (counted from 0). $FIRSTNAME = 1; # " " " the First Name. $STREET = 2; # " " " Street. $PLZ = 3; # " " " PLZ. Note: I'm not sure how the PLZ # in America is called. Probably Postcode or ZIP Code. # Please send mail to iblech@web.de. Thanks! $CITY = 4; # Column number of the City/Town. $t = ''; # Temporary variable. $DELI = 9; # Number of rows of each entry. unless ($HEADER == 0); while(not eof) { chomp($t = ); @l1 = split(";", $t); chomp($t = ); @l2 = split(";", $t); chomp($t = ); @l3 = split(";", $t); print "$l1[$FIRSTNAME] $l1[$FAMNAME]", ' ' x (25 - (length($l1[$FIRSTNAME]) + length($l1[$FAMNAME]))), "$l2[$FIRSTNAME] $l2[$FAMNAME]", ' ' x (25 - (length($l2[$FIRSTNAME]) + length($l2[$FAMNAME]))), "$l3[$FIRSTNAME] $l3[$FAMNAME]\n"; print "$l1[$STREET]", " " x (26 - length($l1[$STREET])), "$l2[$STREET]", " " x (26 - length($l2[$STREET])), "$l3[$STREET]\n"; print "\n"; print "$l1[$PLZ] $l1[$CITY]", ' ' x (25 - (length($l1[$PLZ]) + length($l1[$CITY]))), "$l2[$PLZ] $l2[$CITY]", ' ' x (25 - (length($l2[$PLZ]) + length($l2[$CITY]))), "$l3[$PLZ] $l3[$CITY]\n"; print "\n" x ($DELI - 4); } --------/CODE-------- Happy printing! ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- This document is distributed under the terms of the GNU Free Documentation License.