# Tag Info

## Hot answers tagged datatool

18

You can use pgfplotstable for this. If you load the array package, you can set the option dec sep align for pgfplotstabletypeset to get the alignment at the decimal point. Padding the numbers with zeros can be accomplished by setting fixed zerofill, the number of decimals can be set using precision, either for all columns or for individual columns by using ...

14

The usual answer here is the pgfplots package, which is based on TikZ. Note that it does not do pie charts, as these are considered misleading by many people. (There is some discussion of this issue in the TikZ manual.) (Note: As mathematicians use 'graphs' for something entirely different, the usual way to refer to data display in a graphical form is as a ...

12

My datatool skills are limited, so the following solution uses TeX primitives and PGFs mathematical engine and also its \pgfutil@in@ macro/conditional. Interaction Line 99: Minimum ratio a Cardinal needs to get elected as Pope. \pgfmathparse{2/3*\the\value{sumVotes}} Line 70: Number of Cardinals that will be marked if no one has reached the limit. As ...

10

The problem lies with the trailing spaces in your CSV currency values. Because of them, the numbers are treated as strings and the internal conversion from currency to decimal that takes place fails. So with the following CSV: a,"$100,090.06","$107,578.03",0.129565278 b,"$267,697.13","$72,463.54",0.087442318 c,"$761,314.81","$192,210.83",0.231820008 some ...

10

TeX's registers can be addressed either by name or by number. To keep a track of the numbers allocated to names, it is necessary to have an allocation routine, which \newcount provides an interface for. Thus when you do \newcount\foo you define \foo to mean \count<number>, and mark <number> as 'taken'. If you subsequently do ...

9

Joseph has explained the reason why the problem arises. Here's a possible workaround. I define a set of macros that set up two pools of token registers and count registers, from which to choose new ones when \DTLdbnewdb is called and that are reinserted in the pool when \DTLdeletedb is issued. One can increase the size of the pool, with the following macros ...

9

Assuming that the first row is the name of the columns, then you simply need to load the database via \DTLloaddb{myDB}{MyData.csv} where the file MyData.csv contains the contents as shown above, and the you can use the internal function \DTLdisplaydb{myDB} to print it as a table. This table is very wide so I used the geometry package to extend the width of ...

9

\DTLforeach visits the rows one after another. Therefore the row order of the data base matters: \DTLforeach*[\DTLisSubString{#2}{\RowID}]{#1}{% % #2 = list of rowIDs In the following solution I have put the data extraction in a for loop that iterates over the given row IDs. There are many for loops, e.g. LaTeX's \@for. I am using \comma@parse from ...

9

(La)TeX tabulars do not require a predefined number for the rows. For the columns, however, this is required in the general setup. You can combine column specifications that are similar though using a *{<num>}{<col spec>} specification. This would repeat <col spec> a total of <num> times. Therefore, defining \begin{tabular}{ | ...

8

When using \DTLforeach with \hline it's generally better to use the following schematic structure which puts the \\ and the \hline at the beginning of each non-initial row instead of at the end of each row. \DTLforeach{<database>}{<assignments>}{% \DTLiffirstrow{}{\\\hline} rest of table with no final \\ } For your second problem, there may ...

8

There's no problem to do this with the datatool package and siunitx as well. Here's your example done in that way: \documentclass{article} \usepackage{datatool} \usepackage{siunitx} \usepackage{booktabs} % for nicer tables \usepackage{caption} % improve caption spacing (among other things) \usepackage{bm} \renewcommand*\dtldisplaystarttab{\toprule} ...

8

I've just uploaded v2.13 to CTAN. It will probably take a day or so to propagate through the mirrors and distros, but once it's available you can use the code below. The best solution is to only define the database once (before the loop) and clear it each time round the loop. This means that you're not constantly allocating new registers. The new version ...

8

When using the babel package with the french option, semicolons (and colons, exclamation marks and question marks) are made active so the spacing around these punctuation symbols can be corrected for the French style of putting space before and after the symbol: "Normal" spacing: French spacing: If you use the semicolon as the field separator in your ...

7

Not sure about the datatool usage, but if you just want to process a comma separated list I think that package is a lot more powerful than you need. The following plain TeX produces \$ tex ll5 This is TeX, Version 3.1415926 (Web2C 2010) (./ll5.tex [ABC, DEF, ABC, MMM, MMM, JHM] -> [ABC,DEF,MMM,JHM] [ABC] -> [ABC] [] -> [] [xx, yyy, xx, yyy, sss] ...

7

\csname is a useful construct for defining a "dynamic" macro name based on some input, but when you're using the same basic structure in different places, you have to make sure the constructed macro names really match up. For instance, comparing this \expandafter\gdef\csname\Dir Color\endcsname{\ExpandedDirColor}% with that ...

7

The example below defines some commands that allow you to add entries to multiple databases. You can then use the example command \xgls instead of \gls and it will index the entries for each of the databases. So if pdf is in the glossary, acronym and index database, \xgls{pdf} will add a location to each database, whereas if html is only in the acronym and ...

7

datatool already loads fp which provides \FPround{<out>}{<in>}{<num>}, rounding <in> to <num> decimal places and stores it in <out>. datatool mirrors this with \DTLround (and/or \DTLtrunc if you wish to truncate rather than round): \documentclass{article} \usepackage{datatool,filecontents}% ...

7

Here's a possible solution: \documentclass{article} \usepackage{eso-pic} \usepackage{fancyhdr} \usepackage{blindtext} % just for the example \usepackage[headsep=3cm,top=5cm]{geometry} \usepackage{datatool} % create sample csv file \begin{filecontents*}{test.csv} Id,myauthor,mydate,myaddress 1,Sebastian,12.12.2012,XYZ road,XYZ city 2,Rose,12.12.2013,XYZ ...

7

You can first of all use a macro to hold the name of the .csv file in abc.tex: \documentclass{article} \usepackage{datatool} \begin{document} ... \DTLloaddb[noheader,keys={Temperature,Time,T2G}]{data}{\csvname.csv} ... \end{document} Then you can call xelatex from the command line by saying xelatex -jobname=abc-pqr '\def\csvname{pqr}\input{abc}' ...

7

You can set the starting angle of the first segment by the setting start=90. The value is 0 by default. \DTLpiechart{variable=\quantity,outerlabel=\name,start=90,radius=1.8cm,outerratio=1.1}{institute}{% \name=Name,\quantity=Quantity} I have made some other changes too in the settings so that the chart looks more good. \documentclass{beamer} ...

6

\documentclass{article} \usepackage{array} \usepackage{longtable} \makeatletter \let\oldref\ref \def\ref#1{\immediate\write\@auxout{\string\expandafter\gdef\noexpand\csname REF:#1\string\endcsname{}}% \oldref{#1}} \def\zz#1#2{\noalign{% \expandafter\ifx\csname REF:#1\endcsname\@empty \def\@currentlabel{#2}\label{#1}% \else \aftergroup\zzapline \fi}#2} ...

6

As Percusse pointed out, PGFPlots first collects all TikZ commands (like \draw) and then executes them at the very end of the axis environment, which leads to the last circle being drawn three times: during every loop iteration, another \draw (axis cs:\x,\y)... is added to the list of commands, and at the very end, when \x and \y contain -3 and -4, ...

6

Deferred writing and package atenddvi Package atenddvi provides the hook \AtEndDvi to get stuff written at the shipout of the last page. Two LaTeX runs are needed at least for knowing, which is the last page. Despite the name the output type DVI, PDF or whatever does not matter. Immediate writing and package atveryend If your data does not contain data ...

6

Both simple problems. The misplacement of 'Albert' is as mentioned in a comment due to a missing %: \DTLiffirstrow{}{\tabularnewline}% The odd business with the q is caused by having & \tabularnewline at the end of the header row, which mis-places things. Try instead just \\: \documentclass{article} \usepackage{datatool} \usepackage{siunitx} ...

6


6

The \foreach loops execute their code in a group for each step, so they are useless when something must be changed "globally", as is the case for your databases. Here's a way using the patch proposed by Werner; but I used a different command to patch, in order not to change the functionality of \DTLgetlocation: \documentclass{article} ...

6

\documentclass{article} \usepackage{datatool} \usepackage{filecontents} \begin{filecontents*}{\jobname.csv} 1,a 2,a 2,a 2,a 3,a 3,a 4,a 4,a 4,a 4,a 5,a 5,a 6,a 6,a 7,a \end{filecontents*} \DTLloaddb[noheader,keys={num}]{raw}{\jobname.csv} \DTLnewdb{hist} \newcounter{numcnt} % fill table "hist" \newcommand*{\SaveRow}{% \ifnum\value{numcnt}>0 % ...

6

Place the \caption{abc} command in the heading ended by \endfirsthead and use a \caption[]{...} in the repeated heading. the [] form suppresses the writing to the toc file. (See the longtable documentation). As @lockstep noted datatool hides this longtable feature, so you need to unhide it:-) \begin{filecontents*}{dt4.csv} 40,120,40 40,90,60 35,180,20 ...

6

The expansion of \ListOfColumnsToOmit in the last case is {A},\space {C} which is obviously wrong. Even omitting the \space, which serves no purpose, the additional braces don't allow datatool to recognize the column names. If I use \newcommand*{\AddToCommaSeparateList}[3][,]{% % #1 = separator % #2 = listname % #3 = content to add to CSV ...

6

The behaviour is typical of the behaviour when a \special or other whatsit node appears in vertical mode. The document grfguide discusses this in the context of colour specials but it is a general problem. The solution is the same as for colour, avoid the problem by getting in to horizontal mode. This seems to work OK \begin{longtabu}{ >{\mbox{}}X[1,r] ...

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