7

I'm working off the excellent answer provided here: Creating a gls from a spreadsheet

I want to store my entries for the glossaries package in a .csv file, which is (IMHO) easier to edit and visualize than as a raw glossaries entry. The difference between my problem and the one above is that I'm trying to use acronyms, rather than a full glossary entry.

MWE:

\usepackage{datatool}
\usepackage[xindy,% better indexing
  acronym% to allow acronyms
  ]{glossaries} % make glossaries

\makeglossaries
\setacronymstyle{long-short}

\DTLloaddb{data}{GeneralAcro.csv} % load the database .csv file

\DTLforeach*{data}% data set
 {% assignments
  \label=Command,%
  \abbrev=Short,%
  \longv=Long
  }{
  \newacronym{\label}{\abbrev}{\longv}
  }
\begin{document}
 \Gls{ipcc} makes \glspl{gcm} using \glspl{fem}.
 \printglossaries
\end{document}

This gives me the following output when using pdflatex + makeindex + pdflatex:

NULL (IPCC) makes NULLS (GCMs) using NULLs (FEMs)

1 Acronyms FEM NULL

For reference, here is the GeneralAcro.csv file contents:

Command,Short,Long
gcm,GCM,Global Climate Model
ipcc,IPCC,International Panel on Climate Change
fem,FEM,Finite Element Model

1 Answer 1

4

Your MWE gives an error:

! Package datatool Error: Can't assign \longv : there is no key `Long ' in data
 base `data'.

The problem is caused by a spurious space at the end of

  \longv=Long

It's looking for a key called "Long " (note the space) but it doesn't exist, so \longv is set to null, which is what's producing the "NULL" text. Just comment out the space caused by the end of line character:

\DTLforeach*{data}% data set
 {% assignments
  \label=Command,%
  \abbrev=Short,%
  \longv=Long% <--- remove eol
  }{
  \newacronym{\label}{\abbrev}{\longv}
  }

The other problems are caused by lack of expansion when you define the entries. You will also need to use the package option sanitizesort=false otherwise all your entries will have the sort key set to \abbrev and xindy won't be able to sort them correctly. The name and description keys will also need to have their expansion switched on:

\glssetexpandfield{name}
\glssetexpandfield{desc}
3
  • (1) As per your rec I fixed the Long% line, which eliminated the null key. (2) I added the \glssetexpandfield{} lines. I looked through the datatools documentation and didn't find anything naming the fields. Can you provide a list of which keys correspond to which fields? (3) Finally, I'm getting a weird output (fixed the package option too). The text is compiling correctly, but the Acronyms list has only the first (of the three) acronyms listed. Do you know why that might be happening?
    – mbarete
    Commented Jul 5, 2015 at 20:57
  • (2) The key to field mappings are listed in table 4.1 in the Expansion section. (3) Did you remember to add the sanitizesort=false package option? If the default sanitizesort=true is on then the sort key will be \abbrev for all acronym entries which confuses xindy (since xindy can't interpret TeX code) and you'll only get the first acronym listed. Commented Jul 6, 2015 at 14:24
  • You were right, I put the sanitizesort=false option on my regular document and then compiled the MWE I generated.... all set now :)
    – mbarete
    Commented Jul 6, 2015 at 23:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .