[Tex/LaTex] Problem using csvsimple with tab-delimited file

csvsimple

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

Best Answer

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}
Related Question