Original Text below

Edit: I solved it with endless googleing and help from here. Here is my theory: the typos caused expandafter to fail, which caused a dismatch between the chopline command and the rest of the chopped line of the previous loop. Another error was the ifeof. Latex tried to read one line after eof. This caused "read to" to fail

Working code:

The format of the csv must be

academicTitle(might be empty);surname;prename;Street+Number;ZIP-code;city;addressExtension;postbox(0 or certainValue)\n

File begins here:


%What do we do? Delete all the margins!!! How do we do it? By force!!!

%Personal chopline command from https://de.wikibooks.org/wiki/LaTeX-W%C3%B6rterbuch:_Serienbrief_mit_externen_Daten
\def\chopline#1;#2;#3;#4;#5;#6;#7;#8 \\{

\newif\ifmore \moretrue


\openin\quelle=Adressen.csv %Here we get the addresses from


\read\quelle to\zeile

%write you stuff here

\newpage %gets ignored on first page

\vspace*{-0.02\paperwidth} %due to my Brief.pdf
\hspace*{0.0\paperheight}  %same here

\vspace*{-0.23\paperheight} %shift the box where desired
\hspace*{0.65\paperwidth}   %same here
\Titel \ \Vorname \ \Name \ \\
\ifx\Adresszusatz\empty %if it isn't empty, it is printed
\Adresszusatz \\
\ifnum\Postfach=0 %if the value is 0 in the .csv, it isn't printed
Postfach \ \Postfach
\Strasse \ \\
\PLZ \ \Ort

%stop with you writing here





Original Question:

This is my first question. I googled a lot, but I still haven't succeeded.

I have made an automatic generator for letter envelopes. This reads from a csv-file. I stick to the instruction given in de.wikibooks Serienbrief. But unfortunately it won't work.

I use Texmaker and MikTex on Windows 7, but I could change to Manjaro, if necessary.

This is my code:

Former code

It crashes after "read to". This seems to be the problem, but I ca'nt figure out why. Furthermore, the loop doesn't work in ANY way. No matter what kind of loop (loop, whiledo, for) I set up, it only loops once. Even if I set a for-loop to 30 repetitions. Actually it should produce 30 frames.

Don't judge me on using beamer for the envelopes. I would give more tags, but I'm not allowed to.

  • The first thing I spotted is \Straße, which will not work. You have to use \Strasse. Mar 23, 2016 at 9:02
  • Also \NamensTitel should be \Titel and \Nachname is \Name
    – user31729
    Mar 23, 2016 at 9:04
  • And value{Postfach} should be \Postfach.
    – cfr
    Mar 23, 2016 at 18:00

1 Answer 1


Perhaps not the best way, but somewhat 'failsafe' is using the expl3 features and \ior_map_inline command that reads the file line by line and processes the input line.

I've used a sequence to split the line into the several relevant parts.

Please note, that white space must be entered with foo\ some other stuff!




\int_const:Nn \c_maestro_titel_int {1}
\int_const:Nn \c_maestro_vorname_int {2}
\int_const:Nn \c_maestro_name_int {3}
\int_const:Nn \c_maestro_strasse_int {4}
\int_const:Nn \c_maestro_plz_int {5}
\int_const:Nn \c_maestro_ort_int {6}
\int_const:Nn \c_maestro_zusatz_int {7}
\int_const:Nn \c_maestro_postfach_int {8}

\ior_new:N \l_maestro_quelle_stream

\ior_open:Nn  \l_maestro_quelle_stream  {Adressen.csv}

\ior_map_inline:Nn \l_maestro_quelle_stream {%
  \seq_set_split:Nnn \l_tmpa_seq {;} {#1}% Split the sequence

%    \vspace{0.6\paperheight}
%    \hspace{0.6\paperheight}????
    \seq_item:Nn \l_tmpa_seq {\c_maestro_titel_int}~\seq_item:Nn \l_tmpa_seq {\c_maestro_vorname_int}~\seq_item:Nn \l_tmpa_seq {\c_maestro_name_int}\par
    \tl_set:Nx \l_tmpa_tl {\seq_item:Nn \l_tmpa_seq {\c_maestro_zusatz_int}}
    \tl_if_empty:NF \l_tmpa_tl {%
      \tl_use:N \l_tmpa_tl\par
    \tl_set:Nx \l_tmpa_tl {\seq_item:Nn \l_tmpa_seq {\c_maestro_postfach_int}}
    \tl_if_empty:NF \l_tmpa_tl {%
      Postfach~\tl_use:N \l_tmpa_tl\par
    \seq_item:Nn \l_tmpa_seq {\c_maestro_strasse_int}\par
    \seq_item:Nn \l_tmpa_seq {\c_maestro_plz_int}~\seq_item:Nn \l_tmpa_seq {\c_maestro_ort_int}


And Adressen.csv is here:

;Gandalf;Stormcrow;Shireroad;10000;Shire;bei\ Schmidt;11111
;Baggins;Bilbo;Shireroad;10000;Shire;bei\ Müller;22222
Dwarf-King;Thorin;Oak-Shield;Erebor\ Road;Middle\ Earth;Arkenstone;at\ Smaug's\ cave;33333

enter image description here

  • Since this is a solutions, I mark this as solution, though I solved it myself. Mar 26, 2016 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.