2

The problem

I am having a problem reading tab-delimited files using csv-simple. My question is how do I fix it, and why is it occuring in the first place

MWE

\documentclass[a4paper]{article}

\usepackage{csvsimple}
\usepackage[centering,margin=1in]{geometry}

\begin{filecontents*}{\jobname.csv}
abc def
fgh ijk
\end{filecontents*}

\begin{document}
\begin{tabbing}
\hspace*{2cm}\=\hspace*{2.5cm}\= \kill
\csvreader[head=false,separator=tab]{\jobname.csv}{1=\word,2=\meaning}{\word \> \meaning\\}
\end{tabbing}
\end{document}

Problem

! Undefined control sequence.                                                                            
\meaning ->\csvcolii

Update 1

So it was suggested that filecontents* does not preserve tabs. So I created a separate file with tabs, and updated my code.

Both of them are here: https://gist.github.com/deepakjois/7d70ef87b061c97f91e9

Now I am getting a really funny output, where the second column of the first row is repeating for all the rows.

screenshot

3
  • I think \meaning is a reserved LaTeX command. Shows you the content of a macro.
    – musicman
    Commented Nov 26, 2015 at 19:33
  • 1
    Note that filecontents* doesn't output tab characters.
    – egreg
    Commented Nov 26, 2015 at 21:13
  • @egreg You may be right. I edited the file and inserted my own tab character, but I am having some other problem. Let me update my question.
    – vyom
    Commented Nov 27, 2015 at 2:47

1 Answer 1

3

You can't use \meaning because it's a reserved command to print out a macros command, for example \meaning\csvreader.

I just can recommend you to always use individual prefixes for your macros.

MWE:

\documentclass[a4paper]{article}
\usepackage{csvsimple}
\usepackage[centering,margin=1in]{geometry}
\begin{document}
\csvreader[tabbing, no head, separator=tab, table head=\hspace*{5cm}\=\hspace*{5cm}\=\kill]{\jobname.csv}{1=\mycsvword,2=\mycsvmeaning}{\mycsvword \> \mycsvmeaning\\}
\end{document}
7
  • 1
    I don't think this is the problem
    – egreg
    Commented Nov 26, 2015 at 21:13
  • I tried substituting \meaning to \mycsvmean, but it still does not work. Still gives the same error: ! Undefined control sequence.\mycsvmean ->\csvcolii
    – vyom
    Commented Nov 27, 2015 at 2:42
  • 1
    did u try it with my MWE? because it's working...
    – musicman
    Commented Nov 27, 2015 at 6:59
  • I can confirm that your answer is working on my system. Commented Nov 27, 2015 at 7:16
  • @ThomasF.Sturm I get the same as vyom (see the update).
    – egreg
    Commented Nov 27, 2015 at 9:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .