2

I want to read from a csv file:

\documentclass{article}
\usepackage{csvsimple}
\begin{document}
\csvautotabular{initial.csv}
\end{document}

Now my initial.csv file looks like this:

a, # b 
1, 3

It creates the following errors:

Illegal parameter number in definition of \csv@col@body \csvautotabular{initial.csv}
Illegal parameter number in definition of \csv@temp \csvautotabular{initial.csv}
You can't use `macro parameter character #' in restricted horizontal mode \csvautotabular{initial.csv}

Then I tried with replacing # by \#. It gives:

Missing \endcsname inserted \csvautotabular{initial.csv}
Extra \endcsname \csvautotabular{initial.csv}
File ended while scanning use of \pgfkeys@temp

Any idea on how should I try if my csv file contains some #'s?

  • 1
    {\catcode`#=12 \csvautotabular{initial.csv}} – wipet Aug 15 '14 at 4:04
3

As @wipet wrote, the problem is the catcode of the # sign. With the recent version 1.12 (2014/07/14) of csvsimple, you can neutralize the # sign with the respect sharp option:

\documentclass{article}
\usepackage{csvsimple}
\begin{document}
\csvautotabular[respect sharp]{initial.csv}
\end{document}

enter image description here

There are some more respect xy options which also may be interesting for other use cases, e.g. respect and (for &) and respect dollar (for $).

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.