I'm currently trying to import a set of data from a file (comma or tabbed delimited, doesn't matter) for creating a table. Below is an example of this data (DH parameters in case you're curious):
Link \alpha a \theta d
0 0 0 0 0
1 \frac{\pi}{2} 0 \theta_{1} 340
2 \frac{-\pi}{2} 0 \theta_{2} 0
3 \frac{-\pi}{2} 0 \theta_{3} 400
4 \frac{\pi}{2} 0 \theta_{4} 0
5 \frac{\pi}{2} 0 \theta_{5} 400
6 \frac{-\pi}{2} 0 \theta_{6} 0
7 0 0 \theta_{7} 0
I've tried both pgfplots and csvsimple without any success. From the errors I receive, they always seem to have difficulty with the special characters. Interestingly, csvsimple's example with "Weißbäck" only works if "Weißbäck" isn't in the header row.
Would anyone happen to have a workflow for import non-standard data with special symbols for tables?
*** EDIT: Simple Test Cases Below…
= Given Tex file:
\documentclass{letter}
\usepackage[utf8]{inputenc}
\usepackage{csvsimple}
\begin{document}
\csvautotabular{./csv/test.csv}
\csvautotabular{./csv/test2.csv}
\end{document}
= Given test.csv (to prove simple case works):
a,b,c
2,2,8
3,6,9
= Given test2.csv:
\ss,b,c
2,2,8
3,6,9
- ERROR:
! Package csvsimple Error: File './csv/test2.csv' starts with an empty line!.
= Given test2.csv:
$\ss$,b,c
2,2,8
3,6,9
ERROR:
! Missing \endcsname inserted.
\OT1\ss
l.9 \csvautotabular{./csv/test2.csv}
The control sequence marked should
not appear between \csname and \endcsname.
! Extra \endcsname.
= Given test2.csv (similar to csvsimple example, but special character is in header row):
\ss{},b,c
2,2,8
3,6,9
ERROR:
! Package csvsimple Error: File './csv/test2.csv' starts with an empty line!.
= Given test2.csv (similar to csvsimple example, special character is in the body):
a,b,c
1,\ss{},8
3,6,9
Works as expected!
Best Answer
Your question is quite general and such not easy to answer. But, if I understand you right, you want to use special characters in your table head and you want to read them from your csv file.
The
\csvautotabular
macro is intended for quick survey only and not for productive tables, since it is quite restricted.\csvreader
or\csvloop
are indented for normal usage.To use the first line of a csv file as normal data line, you have to say
no head
and also to givecolumn count
since this first line is not read as pattern. Then, this line can be used as data line.Still, there is and will be an important restriction: A line is not allowed to start with a backslash
\
.Now, here comes an example: