Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am new to LaTeX and am compiling a document right now using TeXworks. I am trying to create CSV tables into my document right now, and although I succeed in between I must have some small bug in the code which I just cannot spot (trust me I looked for hours).

My code is the following:

\documentclass[9pt]{article}

% Load packages

%************************************************************

\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
    \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=0.75in,rmargin=0.75in}
\usepackage{textcomp}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{rotating}
\usepackage{datatool} % Allows importing tables
\usepackage{enumerate} % Allows latin I option

\renewcommand{\tabcolsep}{2pt}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}



\DTLsetseparator{,}
\DTLloaddb{tarea}{table_test.csv}

\begin{table}
  \caption{Area}
  \centering
  \DTLdisplaydb{tarea}
\end{table}

\end{document}

Latex gives me the following errors:

Error 1

undefined
34
! Argument of \@dtl@trim has an extra }.
<inserted text> 
                \par 
l.34 \beginstable}

Error 2

undefined
?
LaTeX Warning: Unused global option(s):
    [9pt].

Error 3

undefined
?
Package geometry Warning: The marginal notes overrun the paper.
     Add 21.7975pt and more to the right margin.
share|improve this question

closed as too localized by Jake, Stefan Kottwitz Apr 24 '12 at 17:02

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
I never even knew you could do that with LaTeX so I'm afraid I'm not of much help here but if you don't need to load changing tables over and over again but just have one table that you want to show in a document, you can import CSV in gnumeric and export it as LaTeX document or LaTeX fragment. That would also allow some formatting in the table (which you can then do WYSIWYG-style). –  Christian Apr 24 '12 at 15:44
    
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  topskip Apr 24 '12 at 15:48
1  
@Max: Could you provide a dummy sample of your datafile? –  Jake Apr 24 '12 at 15:51
    
Errors 2 & 3 are not really errors but warnings. That aside, Could you give more detail (in terms of the .log output) for error 1? What is written before "undefined"? –  Werner Apr 24 '12 at 15:52
    
As Jake says, we really need the table_test.csv file. I understand if that you may not want to provide that complete file, but what I would recommend is that you start removing chunks of that file until the error goes away - then you know that the problem was in the last chunk you deleted. Repeat this process until you are able to get the table_test.csv as small as possible. If the problem is not obvious, you could post that here, and change any confidential text. –  Peter Grill Apr 24 '12 at 16:47

1 Answer 1

May I suggest you to use pgfplotstable? It works great with CSV files and gives you a lot of control. Here's a nice example:

\documentclass[oneside]{article}

\usepackage{pgfplotstable}
% recommended:
\usepackage{booktabs}
\usepackage{array}
\usepackage{colortbl}

\pgfplotstableset{col sep=comma}

\begin{document}



\begin{table}
\centering
\pgfplotstabletypeset[%
    % Sort the values 
    sort, sort key=error2,
    %
    % The columns to be printed
    columns={dof,error1,{grad(log(dof),log(error2))}},
    %
    % Columns styles
    columns/error1/.style={
        % Name
        column name=$L_2$,
        % Notation and padding
        sci,sci zerofill, sci subscript,
        precision=3},
    columns/dof/.style={
        sci, sci sep align, 
        column name=\textsc{Dof}},
    columns/{grad(log(dof),log(error2))}/.style={
        column name=slopes $L_2$,
        fixed, fixed zerofill,
        % Align decimal deparators
        dec sep align, 
        precision=1},
    %
    % Some colors.
    every even row/.style={
        before row={\rowcolor[gray]{0.9}}},
    every head row/.style={
        before row=\toprule,after row=\midrule},
    every last row/.style={
        after row=\bottomrule},
        ]{data.csv}
\end{table}

\end{document}

Nice and neat table

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.