I am trying to output a *.csv file to LaTeX, but I keep on getting invalid output. I am using mactex on a yosemite environment.
code.csv:
code,subcd
CITY,LIMA
CITY,PUEBLOLIBRE
CITY,JESUSMARIA
CITY,TARMA
preamble:
\documentclass[10pt]{article}
\usepackage{graphicx,fancyhdr,import,hyperref}
\usepackage{longtable,csvsimple}
\usepackage[margin=.75in]{geometry}
\usepackage[toc,page]{appendix}
using csvreader:
\begin{document}
\section{System Constants}
The following table contains the constants used throughtout the system.
\begin{tabular}{|c|c|}
\csvreader[head to column names]{code.csv}{}{}
\end{tabular}
\end{document}
my output:
I am not sure what I'm doing wrong.
Also, I saw in Importing CSV file as a table in Latex but file too long that one can split a table that is too long into multiple tables with the same header (my table eventually will grow in size and I thought it would be a good idea to account for it). However, after trying the samples in the post above, I seem to get errors.
.tex file:
\section{System Constants}
The following table contains the constants used throughtout the system.
%\csvautotabular{tables/code.csv}
%\begin{tabular}{|c|c|}
%\csvreader[head to column names]{code.csv}{}{}
%\end{tabular}
\csvreader[
longtable=lrrrr,
table head=
\toprule\bfseries Code & \bfseries Sub Code \\
\midrule\endhead
\bottomrule\endfoot,
late after line=\\,
before reading={\catcode`\#12},
after reading={\catcode`\#12}
]{code.csv}{}{}
Any ideas on how to use csvsimple
with longtable
?
Any help would be appreciated!
EDIT:
after some research on csvsimple and pointed on the right direction by Thomas F. Sturm, I found out that I was using the tool incorrectly. The following is an updated version of the .tex code and also note that I've updated the .csv file to subcd
\csvreader[
longtable=|l|l|,
table head=
\toprule
\bfseries Code & \bfseries Sub Code\\
\midrule
\endhead
\bottomrule,
table foot=\bottomrule
]{code.csv}{1=\code, 2=\subcd}{\code & \subcd}
However, I seem to get a compilation error on the last line {\code & \subcd}
Best Answer
Take datatool. :)