4

I have a CSV file composed as shown below (I reported only a small part of it as it is very long). The actual separator I chose to use is '|' (pipe), as the file content might also include comma. Each row is composed of 5 fields.

keyword|type|range of value|m.u.|description
version|uint32_t| current  version |-| version of  the  FGFS  structure  in  use  (check  net_fdm.hxx  for  its  value).  It  is  not  necessary  to  assign  a  value  to  this  field,  it  is  detected  automatically. 
padding|uint32_t|none|-| not  used.  Never  assign  a  value. 
longitude|double|[-180,+180]|rad| geodetic  longitude 
latitude|double|[-90,+90]|rad| geodetic  latitude 
altitude|double|-|m| altitude  above  sea  level 
agl|float|-|m| altitude  above  ground  level 
phi|float|[-180,+180]|rad| roll  angle 
theta|float|[-180,+180]|rad| pitch  angle 
psi|float|[-180,+180]|rad| true  heading 
alpha|float|-|rad| angle  of  attack 
beta|float|-|rad| side  slip  angle 

I want to load this CSV file by way of \csvreader, which I enclosed in environment \xltabular, in order to create a multipage table where the 5° column is allowed to automatically break line (the 5° column is expected to contain long sentences). Here below my MWE.

\documentclass{article}

\usepackage{longtable}
\usepackage{xltabular}
\usepackage{csvsimple}
\usepackage{booktabs}

\begin{document}

\begin{xltabular}{\linewidth}{llrlX}\toprule
\midrule
\csvreader[
    late after line=\\\midrule,
    late after last line=\\\bottomrule,
    respect underscore = true,
    separator = pipe,]
{./FDMNet.csv}{}{}
\end{xltabular}

\end{document}

Although no compile error is given, the table remains empty.

enter image description here

How do I fix this issue? Any help would be appreciated. Thanks in advance.

2
  • Welcome! Anything in the log? – cfr Feb 8 '18 at 1:23
  • Not familiar with the package, but you don't seem to have asked it to actually typeset any information, so it doesn't typeset any - just as you asked. – cfr Feb 8 '18 at 1:27
1

The syntax is (page 8):

\csvreader[options]{file name}{assignments}{command list}

The problem is that your code doesn't assign or use anything. It loads the table, but it doesn't ask for anything to be typeset. So it isn't.

You can not use any assignments, but if your command list is empty, nothing is done.

If that's corrected, it works except that respect underscore does not agree with tabularx, so you either have to protect your underscores or use a different environment. Since tabularx isn't mentioned in the csvsimple's manual, I guess it is not too surprising if it does not work here.

\begin{filecontents*}{\jobname.csv}
keyword|type|range of value|m.u.|description
version|uint32\_t| current  version |-| version of  the  FGFS  structure  in  use  (check  net_fdm.hxx  for  its  value).  It  is  not  necessary  to  assign  a  value  to  this  field,  it  is  detected  automatically. 
padding|uint32\_t|none|-| not  used.  Never  assign  a  value. 
longitude|double|[-180,+180]|rad| geodetic  longitude 
latitude|double|[-90,+90]|rad| geodetic  latitude 
altitude|double|-|m| altitude  above  sea  level 
agl|float|-|m| altitude  above  ground  level 
phi|float|[-180,+180]|rad| roll  angle 
theta|float|[-180,+180]|rad| pitch  angle 
psi|float|[-180,+180]|rad| true  heading 
alpha|float|-|rad| angle  of  attack 
beta|float|-|rad| side  slip  angle 
\end{filecontents*}

\documentclass{article}
\usepackage{longtable}
\usepackage{xltabular}
\usepackage{csvsimple}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\begin{document}
\begin{xltabular}{\linewidth}{llrlX}\toprule
  \csvreader[
  late after line=\\\midrule,
  late after last line=\\\bottomrule,
  respect underscore = true,
  separator = pipe,]
  {\jobname.csv}{}{\csvcoli & \csvcolii & \csvcoliii & \csvcoliv & \csvcolv }
\end{xltabular}
\end{document}

table with content

3
  • Thanks for your help! It works! But it doesn't show table header... why? – Luca Conti Feb 8 '18 at 11:09
  • @LucaConti Dunno. Was it meant to? I've never used this package before and don't know what it is meant to do exactly. – cfr Feb 9 '18 at 0:41
  • Yes, it is supposed to use the first row in the CSV file as table header, from what I've seen on documentation. It doesn't matter, I added my header manually. Thank you again for your help! – Luca Conti Feb 9 '18 at 7:22

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.