1

1) Semicolon ; separator and babel

Using the package csvsimple, I found that I can use a semicolon ; separator only if the babel package is not loaded:

\documentclass[varwidth,margin=0.5cm]{standalone}

\usepackage[french]{babel} % Comment to avoid error
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csvsimple}

\begin{filecontents*}{TestSemicolon.csv}
surname;name
MOUSE;Mickey
DUCK;Donald
\end{filecontents*}

\begin{document}
  \csvreader[
    head to column names,
    separator=semicolon,
    ]{TestSemicolon.csv}{}{%
    \surname~\name\\
    }%
\end{document}

I get the following error since \surname and \name appear not to be defined:

Undefined control sequence

2) Comma , separator and babel

Whereas, if I use a comma , separator (default option in csvsimple), everything seems to be working fine:

\documentclass[varwidth,margin=0.5cm]{standalone}

\usepackage[french]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csvsimple}

\begin{filecontents*}{TestComma.csv}
surname,name
MOUSE,Mickey
DUCK,Donald
\end{filecontents*}

\begin{document}
  \csvreader[
    head to column names,
    ]{TestComma.csv}{}{%
    \surname~\name\\
    }%
\end{document}

Output with a comma separator and babel loaded

Is it possible to use a semicolon ; separator with csvsimple together with babel?

  • 1
    This only seems to be reproducible with \usepackage[french]{babel}. Using a different language option such as english, spanish or ngerman results in the desired output. – leandriis Mar 18 '18 at 11:54
  • On my computer, I had tried with \usepackage[spanish]{babel} but I was running into a different Missing \endcsname inserted error... Maybe I did something wrong. I will change the question accordingly, thank you! – remjg Mar 18 '18 at 12:16
1

You have to disable the special meaning ; has with babel-french:

\begin{filecontents*}{\jobname-semicolon.csv}
surname;name
MOUSE;Mickey
DUCK;Donald
\end{filecontents*}

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{csvsimple}

\begin{document}

\noindent
\csvreader[
  before reading=\shorthandoff{;},
  head to column names,
  separator=semicolon,
]{\jobname-semicolon.csv}{}{%
    \surname~\name\\
}
and some other text.

\end{document}

Avoid utf8x, it has been unmaintained for several years.

enter image description here

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.