Tux L i n u x * G u i d e

v o n * I n g o * B l e c h s c h m i d t * ( c ) * 2 0 0 1
Tux
|Home|

|Neue Artikel|

|Index|

|Liste|

|Code-Snippets|

|Links|

|Allgemeines|

|Cool Stuff|
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...

LinuxGuide Druckbare Version
Man-Page
Sourcecode
Verwandte Artikel:

Karteikarten drucken
LPHTML-Tools
Seiten zählen und drucken



      .~.   
      /V\   
     // \\  
    /(   )\ 
     ^`~'^  
     


Hosted at Sorceforge.net
No ePATENTS
Viewable With Any Browser
Burn All GIFs!

M
ein Skript etiketten.pl erzeugt aus einer CSV-Datei wie die folgende die weiter unten zu sehende Ausgabe:
# 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
 
 

# cat daten.csv | ./etiketten.pl
 
 
 

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$ $ $ $ $
 
 

Damit man die Anordnung besser versteht, wurden alle Leerzeichen durch ~ und alle Zeilenenden durch $ ersetzt.
Das Skript, Download:
# 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.

<STDIN> unless ($HEADER == 0);

while(not eof) {
  chomp($t = <STDIN>); @l1 = split(";", $t);
  chomp($t = <STDIN>); @l2 = split(";", $t);
  chomp($t = <STDIN>); @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);
}

 
 

Happy printing!

Document Informations: Content-Type: text/html; charset=iso-8859-1
Author: Ingo Blechschmidt
Description: LinuxGuide - etiketten.pl kann aus CSV-Daten druckerfreundliche Etiketten machen. Ein bisschen Handarbeit wird aber trotzdem benötigt...
Keywords: Etiketten, drucken, Drucken, etiketten, LinuxGuide
Robots: all
Copyright: Copyright (C) 2002 by Ingo Blechschmidt
Date: 2003-10-23T10:17:28+02:00

Stichwortverzeichnis | Neue Artikel | Übersicht | Codesnippets | Links | Copyright | Cool Stuff | Home | Druckbare Version | Manpage | Sourcecode |
Diesen Artikel kritisieren, kommentieren oder ergänzen
Einen Neuen Artikel schreiben

 
This website is distributed under the GNU Free Documentation License .