20 votes

Use datatool to read a row from a CSV file, then use the variables in the document?

\DTLforeach takes three compulsory arguments, not two as in your example. This fixes your example: \documentclass{memoir} \usepackage{datatool} \DTLsetseparator{|} \DTLloaddb{players}{database.csv} ...
user avatar
13 votes

Populate information from a csv file into a LaTeX document (specifically into the fields/arguments of commands therein)

Quick and dirty expl3 implementation: First you load the CSV file with \LoadCSV{<label>}{<file>}. This command will open the file and load the contents of the CSV into <label>. The ...
user avatar
13 votes
Accepted

What's the best way of typing the following 58 equations into LaTeX?

Here's a possible implementation; the delimiters can be changed. \documentclass{article} \usepackage{amsmath,multicol} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\constraints}{omO{x}} { ...
user avatar
  • 1.0m
12 votes

What's the best way of typing the following 58 equations into LaTeX?

You can automate the job by exporting the Excel spreadsheet to a comma delimited file (for example subscripts.csv) and reading your data with the readarray package. MWE Assuming that the content of ...
user avatar
  • 950
12 votes

What's the best way of typing the following 58 equations into LaTeX?

Use Excel's CONCAT function. It's probably easiest to do this in Excel, especially if it's a one-time thing. Excel has several text-manipulation functions, and I have often found it a very ...
user avatar
  • 447
11 votes

Document using datatool is slow to compile

The datatool package uses an insertion sort algorithm. The gory details, for anyone who's interested, are described in section 4.10 of the datatool documented code. However, I agree with the comments. ...
user avatar
10 votes

Populate information from a csv file into a LaTeX document (specifically into the fields/arguments of commands therein)

Let us say we have the following code: \documentclass[11pt,a4paper,sans]{moderncv} % moderncv themes \moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy \moderncvcolor{blue} \...
user avatar
  • 63.6k
10 votes
Accepted

Populate information from a csv file into a LaTeX document (specifically into the fields/arguments of commands therein)

With readarray (and listofitems included). First, I employ readarray macros \readarraysepchar{\\} \readdef{personalinfo.csv}\myrawdata to take the contents of personalinfo.csv and place it into the ...
user avatar
9 votes

Suppress ampersand in external text

You can set locally the catcode of & when reading the data. It will not disturb the use of & later, and unlike \detokenize it will not break other commands like non-ascii input in your input: ...
user avatar
8 votes

Unexpected result from trying to use \ce{} from mhchem package with a command defined by \DTLgetvalue from the datatool package

It seems that \ce requires its argument to be expanded (presumably because \ce parses it) so you need to use \expandafter to ensure the argument is in the correct format: \expandafter\ce\expandafter{\...
user avatar
8 votes
Accepted

How to count the occurence of M and F in a particular column , No. of male and female deaths?

A variant using datatool and some counters. \documentclass[11pt]{report} \usepackage{filecontents} % this just saves the data to a text file \begin{filecontents*}{deathdata.txt} Sl.,Unique ID,Name,...
user avatar
8 votes
Accepted

Overhanging vertical bars in tabular

The last \\\hline shouldn't be inside the the loop but after it, so that the code of the loop doesn't triggers the creation of a new row: \documentclass{article} \usepackage{datatool} \usepackage{...
user avatar
7 votes

API JSON in Latex

As I hinted in a comment, even if Sharelatex allows to use lualatex as compiler for your documents, it does not allow network connections from luatex code. I performed the following test: Wrote the ...
user avatar
  • 54.6k
7 votes
Accepted

longtable extends unnecessarily to a second page

You are ending every row with \\ inside the \DTLforeach. This means that you are executing code after the final \\ and such code can easily lead to an empty row at the end of the tabular. You can ...
user avatar
7 votes

How to count the occurence of M and F in a particular column , No. of male and female deaths?

Here, if you place your table data in a \def, you can use the created macro \analyze to look for patterns. This macro employs the listofitems package to parse the data in your table, and count the ...
user avatar
7 votes
Accepted

How to align the last element on the right when using \hfill?

There are two obvious problems with your code. You get errors about both of them. Firstly you mistyped \makeatother as \makeatotherx which causes LaTeX to complain ! Undefined control sequence. l....
user avatar
  • 161k
6 votes

Sending Same Letter to multiple addresses

I would suggest using the datatool package (click the image to enlarge it): \documentclass{article} \usepackage{filecontents} \begin{filecontents*}{sample.csv} Name, Address, City, State, Zip Company ...
user avatar
  • 569k
6 votes

Filesize command amount dependent?

If you add \pdfcompresslevel=0 To the top of the document then you get filesizes of 3129555 and 13642 with and without hyperref. Looking in the pdf the first obvious difference is 26368 occurrences ...
user avatar
6 votes
Accepted

Creating table using tabularx and datatool from csv file

datatool keeps track of the rows that it parses when using \DTLforeach[*][<condition>]{<db name>}{<assign list>}{<text>} (from the user guide): The macro \DTLforeach may be ...
user avatar
  • 569k
6 votes
Accepted

API JSON in Latex

I would recommend against trying to import data directly into LaTeX from a REST/JSON API. This would in any case require outside tools as LaTeX cannot open network connections. I'd suggest to use a ...
user avatar
6 votes
Accepted

DTLgetvalueforkey works, but DTLfetch doesn't

The datatool user guide mentions the following about \DTLfetch: \DTLfetch{<db name>}{<col1 name>}{<col1 value>}{<col2 name>} This fetches and displays the value for &...
user avatar
  • 569k
6 votes
Accepted

How can I remove all rows with larger DTLrowi than 10?

It doesn't make sense to remove rows when you're making a table: the removal would be local and wouldn't affect the data base. Just ignore those rows. Also you cannot end a conditional in a different ...
user avatar
  • 1.0m
6 votes
Accepted

How can this complex command be broken down and explained for someone starting with Tex?

\makeatletter and \makeatother are needed in order to allow using command names with @ in them. There is nothing really special about it. The first idea is to use \NewDocumentCommand{\DTLfetchifnull}{...
user avatar
  • 1.0m
6 votes

Misplaced noalign with datatool and booktabs

you are hiding the last \ inside the DTLforeach and this separates it from the \bottomrule. That doesn't work. Build the rows outside the tabular: \documentclass{article} \usepackage{booktabs} \...
user avatar
5 votes

Speed up CSV loading with datatools package?

csvsimple is described as a lightweight tool that doesn't support sorting or data storage, whereas datatool is a heavyweight package that supports both sorting and storage, and it's the extra ...
user avatar
5 votes
Accepted

Merging two datatool databases from different files but with the same columns

Merging of tables with datatool is not natively supported. You'll either have to process the tables externally, or create a new table that represents the union of the tables to be merged. This latter ...
user avatar
  • 569k
5 votes
Accepted

bulk letter with datatool: how to handle linebreak csv-field

If you want to include LaTeX commands in your csv file, you can't use \DTLloadrawdb. If you switch to \DTLloaddb instead, your example works fine with \DTLpar. list.csv: company;firstname;surname ...
user avatar
5 votes
Accepted

Is there a way to store information in something like an array

You can read the file by \read primitive. The data are stored in control sequences \base:id:name. The \data macro simply expands this control sequence. \newread\basein \def\readbase #1 {\bgroup \...
user avatar
  • 54.2k
5 votes
Accepted

Mail merge using datatool with letter class

The argument to \begin{letter} is massaged in order to extract the addressee. This massage is incompatible with \ifthenelse. Here's a way out: we fed the argument in “explicit” form. \documentclass{...
user avatar
  • 1.0m
5 votes
Accepted

\uppercase with datatool does not work

\documentclass[10pt]{article} \usepackage[utf8]{inputenc} \usepackage{datatool} \title{Book of Abstracts for Conference} \author{Albert Einstein} \DTLnewdb{abstacts} \DTLloaddb{abstracts}{...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible