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 trying to compile latex code that imports CSV into a longtable (ltxtable). The code has been compiled successfully in windows while it makes error in Mac OS X.

\documentclass{article}
\usepackage{datatool}
\usepackage{filecontents}
\usepackage{ltxtable}

\begin{document}

%% Read CSV conents
\DTLloaddb[noheader,keys={abbr,desc}]{abbreviations}{abbreviations.csv}
\DTLsort{abbr}{abbreviations}%

%% Write CSV into LaTex file (ltxtable)
\begin{filecontents}{abbreviations.tex}
\begin{longtable}{>{\bfseries}l X}
\DTLforeach{abbreviations}{%
\abbr=abbr,\desc=desc}{%
\\
\abbr& \desc%
}
\end{longtable}
\end{filecontents}

%% Include the LaTex file (ltxtable) 
\LTXtable{\textwidth}{abbreviations.tex}

\end{document}

Error:

Runaway argument?
\@nil \let \@dtl@line =\@dtl@trmstr \ifx \@dtl@line \@longempty \else \ETC.
! File ended while scanning use of \@dtl@trim.

The CSV file has two columns like:

%% Abbreviations List   
FHSS,Frequency Hopping Spread Spectrum
CRLB,"Cram\'{e}r-Rao Lower Bound"
share|improve this question
1  
It is possible that the two computers have different versions of datatool or some other relevant package. You can test this by putting \listfiles in the preamble and comparing the end of the .log for each computer (the command prints the versions of each loaded package). Barring that, unless you get lucky, someone is going to ask for a complete, but minimal example file that demonstrates the problem. Search for 'MWE' if you aren't sure what I'm referring to. –  jon Sep 26 '12 at 19:51
    
Thanks jon, I do not have acces to the Windows machine to compare package versions. I will include the MWE now. I figured out that if I change the CSV into a short simple file it works, but not on the actual one. So I go to investigate the problem by working on the CSV file. –  Aydin Sep 26 '12 at 20:18
    
I am getting the same error message when processing a CSV that has a LaTeX macro in the last column. Seems \DTLforeach gets confused if the column entry doesn't quite fit what is expected; maybe the subsequent newline is gobbled? In my case I worked around this by adding a bogus final column to the CSV, so the line ends with a column separator. –  Arend Jan 22 '13 at 23:25

1 Answer 1

up vote 4 down vote accepted

This may be OS-dependent and related to LaTeX baffled by BOM - Unicode's byte order mark.

Removing the "header" %% Abbreviations List seems to solve the problem.

share|improve this answer
    
Thanks alot Werner, it solved the problem. But it was working on the previous machine with that header! –  Aydin Sep 26 '12 at 20:30
    
I have no problem with the comments (Mac OS X). I suspect something wrong with the Byte Order Mark (BOM) mark that Notepad on Windows is always writing at the beginning (and that's invisible when looking at the file). Removing the first line on the Mac OS X side probably removed also the BOM. –  egreg Sep 26 '12 at 20:32
1  
@egreg: Could be. I created (from a copy-and-paste) abbreviations.csv on ScribTeX and it reproduced the error. Removing the comment also removed the error. –  Werner Sep 26 '12 at 20:37
    
I got a similar error with a comment line starting with % in a csv file when used by datatool. On removing the % the problem disappeared. –  Faheem Mitha Jan 6 at 22:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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