2. ⁑Managing Data
Many of the topics covered in this book have examples that fetch row-and-column style data from an external source, such as in a spreadsheet or structured query language (SQL) database. For example, in §3 Correspondence you may want to pull the recipient's details from a database or you may want to send a template letter to everyone listed in a spreadsheet (mail merging).
This chapter covers accessing data from a CSV file or spreadsheet or from a MySQL database (the most popular open source database [61]). The MySQL Community Edition is freely downloadable, but there are also commercial versions available. The free version can be fetched from http://dev.mysql.com/downloads/mysql/. In addition, this chapter also includes sections on topics that aren't specific to databases, but describe useful utility commands that are used in some of the examples and exercises throughout this book.
There are a number of packages and applications available on CTAN that can be used to fetch data, see the “Data Import” topic. This book covers the datatool bundle (available on modern TeX distributions such as TeX Live and MiKTeX1) and the datatooltk Java application (the installer and source are available on CTAN). This book assumes you have the latest version of datatool installed (version 2.23 at time of writing). If you want to try any of the datatooltk examples here, ensure you are using the latest version (currently 1.6).
\foo{ bar }
is
usually not the same as \foo{bar}
.3 This is because the entire contents of the
argument is data not a variable or list of variables. You may not
like or agree with TeX's unusual syntax, but no one has so far
produced a viable alternative to TeX that has the typesetting
power and flexibility of TeX but the structured coding of popular
programming languages (although LuaTeX comes close). Unless
told otherwise, assume that spaces aren't ignored.
Footnotes
- ...TeX1
- TeX Live is included in the MacTeX distribution, and MiKTeX is included in the ProTeXt distribution.
- ... sequences.2
- Although LaTeX adds the
restriction that document text is only permitted within the
document
environment. - ...
\foo{bar}
.3 - Try doing
\begin{ document }
instead of\begin{document}
in a LaTeX document.
This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-07-4).