| 1 |
%-------------------------------------------- |
| 2 |
% |
| 3 |
% Package pgfplotstable |
| 4 |
% |
| 5 |
% Provides support to read and work with abstract numeric tables of the |
| 6 |
% form |
| 7 |
% |
| 8 |
% COLUMN1 COLUMN2 COLUMN3 |
| 9 |
% 1 2 3 |
| 10 |
% 4 4 552 |
| 11 |
% 1e124 0.00001 1.2345e-12 |
| 12 |
% ... |
| 13 |
% |
| 14 |
% Copyright 2007-2010 by Christian Feuersänger. |
| 15 |
% |
| 16 |
% This program is free software: you can redistribute it and/or modify |
| 17 |
% it under the terms of the GNU General Public License as published by |
| 18 |
% the Free Software Foundation, either version 3 of the License, or |
| 19 |
% (at your option) any later version. |
| 20 |
% |
| 21 |
% This program is distributed in the hope that it will be useful, |
| 22 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 |
% GNU General Public License for more details. |
| 25 |
% |
| 26 |
% You should have received a copy of the GNU General Public License |
| 27 |
% along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 28 |
% |
| 29 |
%-------------------------------------------- |
| 30 |
|
| 31 |
% This file provides a high-level table manipulation and typesetting |
| 32 |
% package. |
| 33 |
% |
| 34 |
% |
| 35 |
% --------------------------------------------- |
| 36 |
% Implementation notes for programmers: |
| 37 |
% --------------------------------------------- |
| 38 |
% |
| 39 |
% The table data structure consists of |
| 40 |
% 1. A name which must be a valid TeX macro like '\table' |
| 41 |
% 2. A column list in the \pgfplotslist format. |
| 42 |
% In fact, the column list is stored in the table's name: |
| 43 |
% \pgfplotslistnewempty\table |
| 44 |
% 3. A "file name" stored in |
| 45 |
% \csname\string<\namemacro>@@table@name\endcsname |
| 46 |
% 4. A "scan line length" number stored in |
| 47 |
% \csname\string<\namemacro>@@table@scanline\endcsname |
| 48 |
% It contains the value of \pgfplotsscanlinelength which has |
| 49 |
% been identified right after \pgfplotstableread. |
| 50 |
% 5. foreach column, there is a list of row-values (a row-vector) in |
| 51 |
% the \pgfplotslist format named |
| 52 |
% \csname\string<\namemacro>@<column name>\endcsname |
| 53 |
% |
| 54 |
|
| 55 |
\newif\ifpgfplotstable@search@header |
| 56 |
\newif\ifpgfplotstable@firstline@is@header |
| 57 |
\newcount\c@pgfplotstable@counta |
| 58 |
\newtoks\t@pgfplotstable@a |
| 59 |
\newif\ifpgfplots@addplotimpl@readcompletely |
| 60 |
% should always be false; use only in grouped internal macros |
| 61 |
\newif\ifpgfplots@table@options@areset |
| 62 |
\newif\ifpgfplots@tableread@to@listener |
| 63 |
\newif\ifpgfplots@tableread@use@begingroup |
| 64 |
\newif\ifpgfplotstable@trimcells |
| 65 |
\newif\ifpgfplotstable@percent@is@letter |
| 66 |
\newif\ifpgfplotstable@search@path@implicit@CWD |
| 67 |
|
| 68 |
\pgfkeys{% |
| 69 |
/pgfplots/table/every table/.style={}, |
| 70 |
/pgfplots/table/.unknown/.code={% |
| 71 |
\pgfplotstable@error@pkg{Sorry, I do not know the key `\pgfkeyscurrentkeyRAW' and I am going to ignore it. Perhaps you need \string\usepackage{pgfplotstable}? (The table typesetting parts are a separate package)}% |
| 72 |
},% |
| 73 |
/pgfplots/table/header/.is choice, |
| 74 |
/pgfplots/table/header/true/.code={\pgfplotstable@firstline@is@headerfalse\pgfplotstable@search@headertrue}, |
| 75 |
/pgfplots/table/header/false/.code={\pgfplotstable@firstline@is@headerfalse\pgfplotstable@search@headerfalse}, |
| 76 |
/pgfplots/table/header/has colnames/.code={\pgfplotstable@firstline@is@headertrue\pgfplotstable@search@headerfalse}, |
| 77 |
/pgfplots/table/header=true, |
| 78 |
/pgfplots/table/search path/.initial=., |
| 79 |
/pgfplots/table/search path/implicit ./.is if=pgfplotstable@search@path@implicit@CWD, |
| 80 |
/pgfplots/table/search path/implicit .=true, |
| 81 |
/pgfplots/table/x index/.initial=0, |
| 82 |
/pgfplots/table/x/.initial=, |
| 83 |
/pgfplots/table/x expr/.initial=, |
| 84 |
/pgfplots/table/y index/.initial=1, |
| 85 |
/pgfplots/table/y/.initial=, |
| 86 |
/pgfplots/table/y expr/.initial=, |
| 87 |
/pgfplots/table/z index/.initial=2, |
| 88 |
/pgfplots/table/z/.initial=, |
| 89 |
/pgfplots/table/z expr/.initial=, |
| 90 |
/pgfplots/table/meta index/.initial=, |
| 91 |
/pgfplots/table/meta/.initial=, |
| 92 |
/pgfplots/table/meta expr/.initial=, |
| 93 |
/pgfplots/table/x error index/.style={ |
| 94 |
x error plus index={#1},% |
| 95 |
x error minus index={#1}% |
| 96 |
}, |
| 97 |
/pgfplots/table/y error index/.style={ |
| 98 |
y error plus index={#1},% |
| 99 |
y error minus index={#1}% |
| 100 |
}, |
| 101 |
/pgfplots/table/z error index/.style={ |
| 102 |
z error plus index={#1},% |
| 103 |
z error minus index={#1}% |
| 104 |
}, |
| 105 |
/pgfplots/table/x error/.style={ |
| 106 |
x error plus={#1},% |
| 107 |
x error minus={#1}% |
| 108 |
}, |
| 109 |
/pgfplots/table/y error/.style={ |
| 110 |
y error plus={#1},% |
| 111 |
y error minus={#1}% |
| 112 |
}, |
| 113 |
/pgfplots/table/z error/.style={ |
| 114 |
z error plus={#1},% |
| 115 |
z error minus={#1}% |
| 116 |
}, |
| 117 |
/pgfplots/table/x error expr/.style={ |
| 118 |
x error plus expr={#1},% |
| 119 |
x error minus expr={#1}% |
| 120 |
}, |
| 121 |
/pgfplots/table/y error expr/.style={ |
| 122 |
y error plus expr={#1},% |
| 123 |
y error minus expr={#1}% |
| 124 |
}, |
| 125 |
/pgfplots/table/z error expr/.style={ |
| 126 |
z error plus expr={#1},% |
| 127 |
z error minus expr={#1}% |
| 128 |
}, |
| 129 |
/pgfplots/table/x error plus index/.initial=, |
| 130 |
/pgfplots/table/y error plus index/.initial=, |
| 131 |
/pgfplots/table/z error plus index/.initial=, |
| 132 |
/pgfplots/table/x error plus/.initial=, |
| 133 |
/pgfplots/table/y error plus/.initial=, |
| 134 |
/pgfplots/table/z error plus/.initial=, |
| 135 |
/pgfplots/table/x error plus expr/.initial=, |
| 136 |
/pgfplots/table/y error plus expr/.initial=, |
| 137 |
/pgfplots/table/z error plus expr/.initial=, |
| 138 |
/pgfplots/table/x error minus index/.initial=, |
| 139 |
/pgfplots/table/y error minus index/.initial=, |
| 140 |
/pgfplots/table/z error minus index/.initial=, |
| 141 |
/pgfplots/table/x error minus/.initial=, |
| 142 |
/pgfplots/table/y error minus/.initial=, |
| 143 |
/pgfplots/table/z error minus/.initial=, |
| 144 |
/pgfplots/table/x error minus expr/.initial=, |
| 145 |
/pgfplots/table/y error minus expr/.initial=, |
| 146 |
/pgfplots/table/z error minus expr/.initial=, |
| 147 |
/pgfplots/table/ignore chars/.initial=, |
| 148 |
/pgfplots/table/white space chars/.initial=, |
| 149 |
/pgfplots/table/text special chars/.initial=, |
| 150 |
/pgfplots/table/percent is letter/.is if=pgfplotstable@percent@is@letter, |
| 151 |
/pgfplots/table/comment chars/.initial=, |
| 152 |
/pgfplots/table/skip first n/.initial=0, |
| 153 |
/pgfplots/table/trim cells/.is if=pgfplotstable@trimcells, |
| 154 |
/pgfplots/table/trim cells/.default=true, |
| 155 |
/pgfplots/table/read completely/.is choice, |
| 156 |
/pgfplots/table/read completely/true/.code= \pgfplots@addplotimpl@readcompletelytrue\def\pgfplots@addplotimpl@readcompletely@auto{0}, |
| 157 |
/pgfplots/table/read completely/false/.code=\pgfplots@addplotimpl@readcompletelyfalse\def\pgfplots@addplotimpl@readcompletely@auto{0}, |
| 158 |
/pgfplots/table/read completely/auto/.code=\pgfplots@addplotimpl@readcompletelyfalse\def\pgfplots@addplotimpl@readcompletely@auto{1}, |
| 159 |
/pgfplots/table/read completely/.default=true, |
| 160 |
/pgfplots/table/read completely=auto, |
| 161 |
/pgfplots/table/text indicator/.initial=, |
| 162 |
/pgfplots/table/col sep/.is choice, |
| 163 |
/pgfplots/table/col sep/space/.code = {\def\pgfplotstableread@COLSEP@CASE{0}}, |
| 164 |
/pgfplots/table/col sep/comma/.code = {\def\pgfplotstableread@COLSEP@CASE{1}}, |
| 165 |
/pgfplots/table/col sep/semicolon/.code = {\def\pgfplotstableread@COLSEP@CASE{2}}, |
| 166 |
/pgfplots/table/col sep/colon/.code = {\def\pgfplotstableread@COLSEP@CASE{3}}, |
| 167 |
/pgfplots/table/col sep/braces/.code = {\def\pgfplotstableread@COLSEP@CASE{4}}, |
| 168 |
/pgfplots/table/col sep/tab/.code = {\def\pgfplotstableread@COLSEP@CASE{5}}, |
| 169 |
/pgfplots/table/col sep/&/.code = {\def\pgfplotstableread@COLSEP@CASE{6}\pgfplotstable@trimcellstrue}, |
| 170 |
/pgfplots/table/col sep/ampersand/.code = {\def\pgfplotstableread@COLSEP@CASE{6}\pgfplotstable@trimcellstrue}, |
| 171 |
/pgfplots/table/col sep=space, |
| 172 |
/pgfplots/table/format/.is choice, |
| 173 |
/pgfplots/table/format/auto/.code = {\def\pgfplotstableread@FORMAT@CASE{0}}, |
| 174 |
/pgfplots/table/format/inline/.code = {\def\pgfplotstableread@FORMAT@CASE{1}}, |
| 175 |
/pgfplots/table/format/file/.code = {\def\pgfplotstableread@FORMAT@CASE{2}}, |
| 176 |
/pgfplots/table/format=auto, |
| 177 |
/pgfplots/table/row sep/.code={% |
| 178 |
\pgfplotsutilifstringequal{#1}{\\}{% |
| 179 |
\def\pgfplotstableread@ROWSEP@CASE{1}% |
| 180 |
}{% |
| 181 |
\pgfplotsutilifstringequal{#1}{crcr}{% |
| 182 |
\def\pgfplotstableread@ROWSEP@CASE{1}% |
| 183 |
}{% |
| 184 |
\pgfplotsutilifstringequal{#1}{newline}{% |
| 185 |
\def\pgfplotstableread@ROWSEP@CASE{0}% |
| 186 |
}{% |
| 187 |
{% |
| 188 |
\t@pgfplots@tokc={#1}% |
| 189 |
\pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, the choice `row sep=\the\t@pgfplots@tokc' is not known. Maybe you misspelled it? Try `\string\\' or `newline'.}\pgfeov% |
| 190 |
}% |
| 191 |
}% |
| 192 |
}% |
| 193 |
}% |
| 194 |
},% |
| 195 |
/pgfplots/table/row sep=newline, |
| 196 |
} |
| 197 |
|
| 198 |
\pgfkeys{ |
| 199 |
% #1: the argument which should have been assigned. |
| 200 |
% #2: an error message. |
| 201 |
/pgfplots/exception/non unique colname/.code 2 args={% |
| 202 |
\ifx\pgfplotsexceptionmsg\relax |
| 203 |
\pgfplots@error{#2}% |
| 204 |
\else |
| 205 |
\pgfplots@error{\pgfplotsexceptionmsg}% |
| 206 |
\fi |
| 207 |
\let#1=\pgfutil@empty |
| 208 |
},% |
| 209 |
/pgfplots/exception/table columns unbalanced/.code={% |
| 210 |
\ifx\pgfplotsexceptionmsg\relax |
| 211 |
\pgfplots@error{#1}% |
| 212 |
\else |
| 213 |
\pgfplots@error{\pgfplotsexceptionmsg}% |
| 214 |
\fi |
| 215 |
}, |
| 216 |
} |
| 217 |
|
| 218 |
% \pgfplotstableread[OPTIONS] {FILE} to \name |
| 219 |
% |
| 220 |
% This method reads a table from FILE to macro \name. |
| 221 |
% |
| 222 |
% FILE is something like |
| 223 |
% G Basis dof L2 A Lmax cgiter maxlevel eps |
| 224 |
% 5 5 5 8.31160034e-02 0.00000000e+00 1.80007647e-01 2 2 -1 |
| 225 |
% 17 17 17 2.54685628e-02 0.00000000e+00 3.75580565e-02 5 3 -1 |
| 226 |
% ... |
| 227 |
% |
| 228 |
% A number format line is also understood: |
| 229 |
% G Basis dof L2 A Lmax cgiter maxlevel eps |
| 230 |
% $flags int int int sci:8 sci:8 sci:8 int int std:8 |
| 231 |
% 5 5 5 8.31160034e-02 0.00000000e+00 1.80007647e-01 2 2 -1 |
| 232 |
% |
| 233 |
% or a three-column-gnuplot file with 2 comment headers like |
| 234 |
% #Curve 0, 20 points |
| 235 |
% #x y type |
| 236 |
% 0.00000 0.00000 i |
| 237 |
% 0.52632 0.50235 i |
| 238 |
% |
| 239 |
% The table data is stored columnwise in lists and can be accessed |
| 240 |
% with the other methods of this package. |
| 241 |
% |
| 242 |
% \pgfplotstableread[<options>]{<file>}{<\macro>} |
| 243 |
% \pgfplotstableread[<options>]{<file>} to listener{<\macro>} |
| 244 |
% \pgfplotstableread* ... |
| 245 |
% |
| 246 |
% The '*' does not protect its local variables with TeX groups, |
| 247 |
% everything is added to the current scope (useful to the 'to |
| 248 |
% listener' thing. |
| 249 |
% |
| 250 |
% The 'to listener' variant does NOT assemble a table data structure. |
| 251 |
% Instead, it processes the input table row-wise and invokes <\macro> |
| 252 |
% after each complete row. During the evaluation of <\macro>, the |
| 253 |
% following methods can be used to query values: |
| 254 |
% \pgfplotstablereadgetcolindex{<index>}{<\macro>} |
| 255 |
% \pgfplotstablereadgetcolname{<name>}{<\macro>} |
| 256 |
% \pgfplotstablereadvalueofcolname{<name>} |
| 257 |
% \pgfplotstablereadvalueofcolindex{<index>} |
| 258 |
% \thisrow{<name>} (equivalent to \pgfplotstablereadvalueofcolname) |
| 259 |
% \getthisrow{<name>}{<\macro>} (equivalent to \pgfplotstablereadgetcolname) |
| 260 |
% \thisrowno{<index>} (equivalent to \pgfplotstablereadvalueofcolindex) |
| 261 |
% \getthisrowno{<index>}{<\macro>} |
| 262 |
% \pgfplotstableforeachcolumn\as{<\iteratemacro>}{<loop body>} |
| 263 |
% (the '\as' is required directly after |
| 264 |
% \pgfplotstableforeachcolumn in this context) |
| 265 |
% Attention: 'to listener' is scoped by TeX groups, so any assignments |
| 266 |
% need to be done globally (or with aftergroup magic). |
| 267 |
% |
| 268 |
% More remarks about scoping: |
| 269 |
% \pgfplotstableread to listener works as follows: |
| 270 |
% \begingroup |
| 271 |
% // load table |
| 272 |
% while file has more lines: |
| 273 |
% load line, read every column; |
| 274 |
% invoke listener; |
| 275 |
% repeat |
| 276 |
% \endgroup |
| 277 |
% |
| 278 |
% In short: all invocations of listener have the same level of |
| 279 |
% scoping: they are inside of one TeX group. But single listener |
| 280 |
% invocations as such are not scoped. Make sure you don't |
| 281 |
% accidentally overwrite one of the internals in listener. And: make |
| 282 |
% sure you don't change temporary registers without scoping them! |
| 283 |
% |
| 284 |
% Note: this command also updates \pgfplotsscanlinelength. |
| 285 |
\def\pgfplotstableread{% |
| 286 |
\pgfutil@ifnextchar*{% |
| 287 |
\pgfplots@tableread@use@begingroupfalse |
| 288 |
\pgfplotstableread@impl@star |
| 289 |
}{% |
| 290 |
\pgfplots@tableread@use@begingrouptrue |
| 291 |
\pgfplotstableread@impl@star*% |
| 292 |
}% |
| 293 |
}% |
| 294 |
\def\pgfplotstableread@impl@star*{% |
| 295 |
\pgfutil@ifnextchar[{% |
| 296 |
\pgfplotstableread@impl |
| 297 |
}{% |
| 298 |
\pgfplotstableread@impl[]% |
| 299 |
}% |
| 300 |
} |
| 301 |
|
| 302 |
% BACKWARDS COMPATIBILITY |
| 303 |
\let\pgfnumtableread=\pgfplotstableread |
| 304 |
|
| 305 |
% Invokes #2 if '#1' is an already loaded table and #3 if not. |
| 306 |
\long\def\pgfplotstable@isloadedtable#1#2#3{% |
| 307 |
\ifcase\pgfplotstableread@ROWSEP@CASE\relax |
| 308 |
% row sep=newline |
| 309 |
\let\pgfplots@loc@TMPa=\pgfplotstableread@NL@other% |
| 310 |
\or |
| 311 |
% row sep=crcr |
| 312 |
\def\pgfplots@loc@TMPa{\\}% |
| 313 |
\fi |
| 314 |
% |
| 315 |
\expandafter\pgfutil@in@\expandafter{\pgfplots@loc@TMPa}{#1}% |
| 316 |
\ifpgfutil@in@ |
| 317 |
% Hah! it contains the row separator! This is NO macro name! |
| 318 |
% -> it is an inline table definition. Don't try to |
| 319 |
% assemble a macro name (may run into out-of-memory) |
| 320 |
#3\relax% |
| 321 |
\else |
| 322 |
% ok, the early-out was not met. Make check: |
| 323 |
\pgfplotsutil@ifdefinedui@withsuffix{#1}{@@table@name}{#2}{#3}% |
| 324 |
\fi |
| 325 |
}% |
| 326 |
|
| 327 |
% If the column name `#1' is a `create on use' speicifcation, #2 is |
| 328 |
% invoked, #3 otherwise. |
| 329 |
\long\def\pgfplotstableifiscreateonuse#1#2#3{% |
| 330 |
\pgfkeysifdefined{/pgfplots/table/create on use/#1/.@cmd}{#2}{% |
| 331 |
\pgfutil@in@{create col/}{#1}% |
| 332 |
\ifpgfutil@in@ |
| 333 |
#2% |
| 334 |
\else |
| 335 |
#3% |
| 336 |
\fi |
| 337 |
}% |
| 338 |
}% |
| 339 |
|
| 340 |
% Defines \pgfplotsretval to be a column name which does not already |
| 341 |
% occur in the column names of table #1. |
| 342 |
\def\pgfplotstablegenerateuniquecolnamefor#1{% |
| 343 |
\begingroup |
| 344 |
\c@pgf@countd=0 |
| 345 |
\pgfplotstableforeachcolumn{#1}\as\pgfplots@loc@TMPa{% |
| 346 |
\def\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% |
| 347 |
\edef\pgfplots@loc@TMPb{autocol\the\c@pgf@countd}% |
| 348 |
\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb |
| 349 |
\advance\c@pgf@countd by1 |
| 350 |
\fi |
| 351 |
}% |
| 352 |
\edef\pgfplotsretval{autocol\the\c@pgf@countd}% |
| 353 |
\pgfmath@smuggleone\pgfplotsretval |
| 354 |
\endgroup |
| 355 |
} |
| 356 |
|
| 357 |
% Returns a column vector in form of \pgfplotslist |
| 358 |
% into #3. |
| 359 |
% |
| 360 |
% #1: the column name (not a macro) |
| 361 |
% #2: the table structure |
| 362 |
% #3: the output macro name. |
| 363 |
% |
| 364 |
% @throw `no such element' on error |
| 365 |
\def\pgfplotstablegetcolumnbyname#1\of#2\to#3{% |
| 366 |
\let#3=\pgfutil@empty% just for sanity checking. |
| 367 |
\pgfplotstable@getcol{#1}\of{#2}\to{#3}\getcolmethod{STD}% |
| 368 |
} |
| 369 |
|
| 370 |
% Declares a new getcolmethod class #1. |
| 371 |
% The argument '#1' can then be used as argument for |
| 372 |
% \pgfplotstable@getcol...\getcolmethod{#1}. |
| 373 |
% |
| 374 |
% #2: a set of keys which redefine the behavior. |
| 375 |
% See below for available choices. |
| 376 |
\def\pgfplotstable@definegetcolmethod#1#2{% |
| 377 |
\edef\pgfplotstable@definegetcolmethod@{#1}% |
| 378 |
\pgfqkeys{/pgfplots/table/@getcol}{% |
| 379 |
% Checks if column '#1' exists in table `#2' and invokes `#3' if that |
| 380 |
% is the case and `#4' if not. |
| 381 |
% |
| 382 |
% Note that the check is only for physically existent columns, no alias |
| 383 |
% or create on use is checked here. |
| 384 |
% #1: colname |
| 385 |
% #2: table struct |
| 386 |
% #3: true code |
| 387 |
% #4: false code |
| 388 |
% FIXME : THIS IS BUGGY: the macro may exist, but is it |
| 389 |
% (still) part of the table!? Currently, there is a workaround |
| 390 |
% such that \pgfplotstablenew cleans up and avoids that case.. |
| 391 |
% and we have no "drop column" currently. |
| 392 |
ifexists =\pgfutil@ifundefined{\string##2@##1}{##4}{##3}, |
| 393 |
% |
| 394 |
% Low level method to return (the actual content) of column #1 of |
| 395 |
% table #2 to macro #3. |
| 396 |
% #1: colname |
| 397 |
% #2: table struct |
| 398 |
% #3: result macro |
| 399 |
getexisting =\expandafter\let\expandafter##3\csname\string##2@##1\endcsname, |
| 400 |
% |
| 401 |
% no arguments, the value is a boolean (0 or 1) |
| 402 |
createonuse =1, |
| 403 |
% |
| 404 |
% error handling. |
| 405 |
% #1: colname |
| 406 |
% #2: table struct |
| 407 |
% #3: result macro |
| 408 |
lazyforbidden=\pgfplotstablegetcolumnbyname@impl@createonuseforbidden{##1}\of{##2}\to{##3}, |
| 409 |
noalias =\pgfplotstablegetcolumnbyname@impl@nosuchalias{##1}\of{##2}\to{##3}, |
| 410 |
nocol =\pgfplotstablegetcolumnbyname@impl@nocolumn{##1}\of{##2}\to{##3}, |
| 411 |
#2% |
| 412 |
}% |
| 413 |
}% |
| 414 |
\pgfqkeys{/pgfplots/table/@getcol}{% |
| 415 |
ifexists/.code ={\expandafter\def\csname pgfplotstable@getcol@ifexists@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2##3##4{#1}},% |
| 416 |
getexisting/.code ={\expandafter\def\csname pgfplotstable@getcol@getexisting@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2\to##3{#1}},% |
| 417 |
createonuse/.code ={\expandafter\def\csname pgfplotstable@getcol@createonuse@\pgfplotstable@definegetcolmethod@\endcsname{#1}},% |
| 418 |
lazyforbidden/.code ={\expandafter\def\csname pgfplotstable@getcol@lazyforbidden@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2\to##3{#1}},% |
| 419 |
noalias/.code ={\expandafter\def\csname pgfplotstable@getcol@noalias@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2\to##3{#1}},% |
| 420 |
nocol/.code ={\expandafter\def\csname pgfplotstable@getcol@nocol@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2\to##3{#1}},% |
| 421 |
}% |
| 422 |
|
| 423 |
\pgfplotstable@definegetcolmethod{STD}{}% |
| 424 |
\pgfplotstable@definegetcolmethod{getptr}{% |
| 425 |
ifexists =\pgfutil@ifundefined{pgfplotstblread@colindex@for@name#1}{#4}{#3},% |
| 426 |
getexisting =\edef#3{\csname pgfplotstblread@colindex@for@name#1\endcsname},% |
| 427 |
} |
| 428 |
\pgfplotstable@definegetcolmethod{resolvename}{% |
| 429 |
getexisting =\edef#3{#1},% |
| 430 |
} |
| 431 |
|
| 432 |
% The low level implementation of \pgfplotstablegetcolumnbyname. |
| 433 |
% |
| 434 |
% #4: is a getcolmethod declared with \pgfplotstable@definegetcolmethod |
| 435 |
% |
| 436 |
% ATTENTION: this macro should be expandable! It is also used inside |
| 437 |
% of \thisrow{}. |
| 438 |
\def\pgfplotstable@getcol#1\of#2\to#3\getcolmethod#4{% |
| 439 |
\csname pgfplotstable@getcol@ifexists@#4\endcsname{#1}\of{#2}{% |
| 440 |
\csname pgfplotstable@getcol@getexisting@#4\endcsname{#1}\of{#2}\to#3% |
| 441 |
}{% |
| 442 |
% Oh, there is no column '#1' in table '#2'! |
| 443 |
% |
| 444 |
% Ok, then check for special features. |
| 445 |
% |
| 446 |
% 1. 'create col/...' |
| 447 |
% 2. 'create on use' |
| 448 |
% 3. 'alias' |
| 449 |
% |
| 450 |
% WARNING : this code has been REPLICATED in |
| 451 |
% *** \pgfplotstablereadvalueofcolname *** |
| 452 |
\if1\csname pgfplotstable@getcol@createonuse@#4\endcsname% |
| 453 |
\pgfutil@in@{create col/}{#1}% |
| 454 |
\ifpgfutil@in@ |
| 455 |
\pgfplotstablegenerateuniquecolnamefor{#2}% |
| 456 |
\def\pgfplotstable@loc@TMPa##1{% |
| 457 |
\pgfkeysdef{/pgfplots/table/create on use/##1}{\pgfkeysalso{#1}}% |
| 458 |
\pgfplotstablecreatecol[/pgfplots/table/create on use/##1]{##1}{#2}% |
| 459 |
% and return the newly generated col: |
| 460 |
\csname pgfplotstable@getcol@getexisting@#4\endcsname{##1}\of{#2}\to#3% |
| 461 |
}% |
| 462 |
\expandafter\pgfplotstable@loc@TMPa\expandafter{\pgfplotsretval}% |
| 463 |
\else |
| 464 |
\pgfplotstable@getcol@next{#1}\of{#2}\to{#3}\getcolmethod{#4}% |
| 465 |
\fi |
| 466 |
\else |
| 467 |
\pgfplotstable@getcol@next{#1}\of{#2}\to{#3}\getcolmethod{#4}% |
| 468 |
\fi |
| 469 |
}% |
| 470 |
}% |
| 471 |
\def\pgfplotstable@getcol@next#1\of#2\to#3\getcolmethod#4{% |
| 472 |
\pgfkeysifdefined{/pgfplots/table/create on use/#1/.@cmd}{% |
| 473 |
% aah - a 'create on use' style exists. Apply it! |
| 474 |
\if1\csname pgfplotstable@getcol@createonuse@#4\endcsname% |
| 475 |
\pgfplotstablecreatecol[/pgfplots/table/create on use/#1]{#1}{#2}% |
| 476 |
% and return the newly generated col: |
| 477 |
\csname pgfplotstable@getcol@getexisting@#4\endcsname{#1}\of{#2}\to#3% |
| 478 |
\else |
| 479 |
\csname pgfplotstable@getcol@lazyforbidden@#4\endcsname{#1}\of{#2}\to#3% |
| 480 |
\fi |
| 481 |
}{% |
| 482 |
% ok, then it is either an alias or it simply doesn't exist |
| 483 |
\pgfkeysifdefined{/pgfplots/table/alias/#1}{% |
| 484 |
\csname pgfplotstable@getcol@ifexists@#4\endcsname{\pgfkeysvalueof{/pgfplots/table/alias/#1}}\of{#2}{% |
| 485 |
\csname pgfplotstable@getcol@getexisting@#4\endcsname{\pgfkeysvalueof{/pgfplots/table/alias/#1}}\of{#2}\to#3% |
| 486 |
}{% |
| 487 |
\csname pgfplotstable@getcol@noalias@#4\endcsname{#1}\of{#2}\to{#3}% |
| 488 |
}% |
| 489 |
}{% |
| 490 |
\csname pgfplotstable@getcol@nocol@#4\endcsname{#1}\of{#2}\to{#3}% |
| 491 |
}% |
| 492 |
}% |
| 493 |
} |
| 494 |
\def\pgfplotstablegetcolumnbyname@impl@createonuseforbidden#1\of#2\to#3{% |
| 495 |
\pgfplotstablegetcolumnbyname@impl@nocolumn@{#1}\of{#2}\to{#3}\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@ |
| 496 |
} |
| 497 |
|
| 498 |
\def\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@#1{% |
| 499 |
\space Note that I found a 'create on use/#1' style, but unfortunately, I can't evaluate it in this context. Please use the 'read completely' key such that it is processed earlier (see the manual for details)% |
| 500 |
}% |
| 501 |
\def\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@disable#1{}% |
| 502 |
|
| 503 |
\def\pgfplotstablegetcolumnbyname@impl@nosuchalias#1\of#2\to#3{ |
| 504 |
\pgfplotstablegetcolumnbyname@impl@nosuchalias@{#1}\of{#2}\to{#3}\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@disable |
| 505 |
}% |
| 506 |
|
| 507 |
\def\pgfplotstablegetcolumnbyname@impl@nosuchalias@#1\of#2\to#3#4{% |
| 508 |
\pgfplotsthrow{no such element}{#3}{Sorry, could not retrieve aliased column '\pgfkeysvalueof{/pgfplots/table/alias/#1}' from table '\pgfplotstablenameof{#2}'. The original request was for '#1', which does not exist either.#4{#1}}\pgfeov% |
| 509 |
}% |
| 510 |
|
| 511 |
\def\pgfplotstablegetcolumnbyname@impl@nocolumn#1\of#2\to#3{% |
| 512 |
\pgfplotstablegetcolumnbyname@impl@nocolumn@{#1}\of{#2}\to{#3}\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@disable |
| 513 |
}% |
| 514 |
\def\pgfplotstablegetcolumnbyname@impl@nocolumn@#1\of#2\to#3#4{% |
| 515 |
\pgfplotsthrow{no such element}{#3}{Sorry, could not retrieve column '#1' from table '\pgfplotstablenameof{#2}'. Please check spelling (or introduce name aliases).#4{#1}}\pgfeov% |
| 516 |
}% |
| 517 |
|
| 518 |
|
| 519 |
% Retrieves the column *NAME* '#1' of table #2 and writes it into |
| 520 |
% '#3'. |
| 521 |
% |
| 522 |
% If there is no such column, column aliases will be checked. Finally |
| 523 |
% if there are no aliases, the command fails with an error. |
| 524 |
% |
| 525 |
% The 'create on use' statements can't be used in this context. |
| 526 |
% @see \pgfplotstablegetcolumnbyname |
| 527 |
% |
| 528 |
% #1: a column name (not a macro) |
| 529 |
% #2: the table structure |
| 530 |
% #3: a macro name which will be filled with the (probably modified) |
| 531 |
% column name into #2. |
| 532 |
\def\pgfplotstableresolvecolname#1\of#2\to#3{% |
| 533 |
\let#3=\pgfutil@empty% just for sanity checking. |
| 534 |
\pgfplotstable@getcol{#1}\of{#2}\to{#3}\getcolmethod{resolvename}% |
| 535 |
} |
| 536 |
|
| 537 |
% Invokes either \pgfplotstablegetcolumnbyindex or |
| 538 |
% \pgfplotstablegetcolumnbyname. |
| 539 |
% |
| 540 |
% #1: either a column name, alias or create on use specification, or |
| 541 |
% [index]<integer> denoting a column index. |
| 542 |
% #2: either a loaded table or a table macro. |
| 543 |
% #3: a macro name which will be filled with the column, in the format |
| 544 |
% accepted of \pgfplotslist... |
| 545 |
\long\def\pgfplotstablegetcolumn#1\of#2\to#3{% |
| 546 |
\begingroup |
| 547 |
\pgfplotstable@isloadedtable{#2}{% |
| 548 |
\pgfplotstablegetcolumnfromstruct{#1}\of{#2}\to{#3}% |
| 549 |
}{% |
| 550 |
\pgfplotstableread{#2}\pgfplotstable@tmptbl |
| 551 |
\pgfplotstablegetcolumnfromstruct{#1}\of\pgfplotstable@tmptbl\to{#3}% |
| 552 |
}% |
| 553 |
\pgfmath@smuggleone#3% |
| 554 |
\endgroup |
| 555 |
}% |
| 556 |
\def\pgfplotstablegetcolumnfromstruct#1\of#2\to#3{% |
| 557 |
\def\pgfplotstable@loc@TMPc{#1}% |
| 558 |
\pgfplotstable@is@colname{\pgfplotstable@loc@TMPc}%% |
| 559 |
\ifpgfplotstableread@foundcolnames |
| 560 |
\else |
| 561 |
\expandafter\pgfplotstablegetcolumnnamebyindex\pgfplotstable@loc@TMPc\of{#2}\to\pgfplotstable@loc@TMPc |
| 562 |
\fi |
| 563 |
\expandafter\pgfplotstablegetcolumnbyname\pgfplotstable@loc@TMPc\of#2\to{#3}% |
| 564 |
}% |
| 565 |
|
| 566 |
% Defines #3 to be the column name of the column with index '#1'. |
| 567 |
% |
| 568 |
% #1: a column index (starting with 0) |
| 569 |
% #2: a loaded table structure |
| 570 |
% #3: an output macro name. |
| 571 |
\def\pgfplotstablegetcolumnnamebyindex#1\of#2\to#3{% |
| 572 |
\pgfplotslistselect#1\of#2\to#3\relax |
| 573 |
}% |
| 574 |
|
| 575 |
% Defines #3 to be the column index of the column with name '#1'. |
| 576 |
% |
| 577 |
% #1: a column name |
| 578 |
% #2: a loaded table structure |
| 579 |
% #3: an output macro name which will be filled with the index (or -1 |
| 580 |
% if there is no such index) |
| 581 |
\def\pgfplotstablegetcolumnindexforname#1\of#2\to#3{% |
| 582 |
\def#3{-1}% |
| 583 |
\edef\pgfplotstablegetcolumnindexforname@@{#1}% |
| 584 |
\pgfplotstableforeachcolumn{#2}\as\pgfplotstablegetcolumnindexforname@{% |
| 585 |
\relax |
| 586 |
\ifx\pgfplotstablegetcolumnindexforname@\pgfplotstablegetcolumnindexforname@@ |
| 587 |
\edef#3{\pgfplotstablecol}% |
| 588 |
\fi |
| 589 |
}% |
| 590 |
}% |
| 591 |
\def\pgfplotstablegetcolumnbyindex#1\of#2\to#3{% |
| 592 |
\pgfplotslistselect#1\of#2\to#3\relax |
| 593 |
\expandafter\pgfplotstablegetcolumnbyname#3\of#2\to{#3}% |
| 594 |
} |
| 595 |
|
| 596 |
\def\pgfplotstablecopy#1\to#2{% |
| 597 |
\let#2=#1% |
| 598 |
\pgfplotstablegetname#1\pgfplotstable@loc@TMPa |
| 599 |
\expandafter\let\csname\string#2@@table@name\endcsname=\pgfplotstable@loc@TMPa |
| 600 |
\expandafter\edef\csname\string#2@@table@scanline\endcsname{\pgfplotstablescanlinelengthof{#1}}% |
| 601 |
\pgfplotslistforeachungrouped#1\as\pgfplotstable@loc@TMPa{% |
| 602 |
\def\pgfplotstable@loc@TMPb{% |
| 603 |
\expandafter\let\csname\string#2@\pgfplotstable@loc@TMPa\endcsname}% |
| 604 |
\expandafter\pgfplotstable@loc@TMPb\csname\string#1@\pgfplotstable@loc@TMPa\endcsname |
| 605 |
}% |
| 606 |
} |
| 607 |
|
| 608 |
% Returns the file name of table '#1' into macro #2. |
| 609 |
\def\pgfplotstablegetname#1#2{% |
| 610 |
\expandafter\let\expandafter#2\csname\string#1@@table@name\endcsname |
| 611 |
} |
| 612 |
|
| 613 |
% expands to the table file name of table '#1' |
| 614 |
\def\pgfplotstablenameof#1{% |
| 615 |
\csname\string#1@@table@name\endcsname |
| 616 |
} |
| 617 |
|
| 618 |
% Returns the value of \pgfplotsscanlinelength for table '#1' into |
| 619 |
% macro #2. |
| 620 |
\def\pgfplotstablegetscanlinelength#1#2{% |
| 621 |
\expandafter\let\expandafter#2\csname\string#1@@table@scanline\endcsname |
| 622 |
}% |
| 623 |
|
| 624 |
% Expands to the scan line length of table '#1'. |
| 625 |
\def\pgfplotstablescanlinelengthof#1{\csname\string#1@@table@scanline\endcsname}% |
| 626 |
|
| 627 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 628 |
% |
| 629 |
% IMPLEMENTATION |
| 630 |
% |
| 631 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 632 |
\newif\ifpgfplotstableread@curline@contains@colnames |
| 633 |
\newif\ifpgfplotstableread@foundcolnames |
| 634 |
\newif\ifpgfplotstableread@skipline |
| 635 |
|
| 636 |
% A method which is necessary to work with inline table data. |
| 637 |
% |
| 638 |
% It does nothing if format=file. |
| 639 |
% |
| 640 |
% It needs to be invoked BEFORE the inline table data has been |
| 641 |
% seen the first time. "Seen" means collected as argument! |
| 642 |
% |
| 643 |
% The macro changes \catcodes in order to implement the 'row sep=newline', |
| 644 |
% some special 'col sep' choices and the 'ignore chars' features. |
| 645 |
% |
| 646 |
% ATTENTION: this changes the processing of ALL following newline |
| 647 |
% characters. |
| 648 |
% @see \pgfplotstablecollectoneargwithpreparecatcodes |
| 649 |
\def\pgfplotstablereadpreparecatcodes{% |
| 650 |
\ifx\pgfplotstablereadrestorecatcodes\relax |
| 651 |
\edef\pgfplotstablereadrestorecatcodes{% |
| 652 |
\noexpand\pgfplotstableuninstallignorechars |
| 653 |
\noexpand\catcode`\noexpand\^^M=\the\catcode`\^^M\noexpand\space |
| 654 |
\noexpand\catcode`\noexpand\ =\the\catcode`\ \noexpand\space |
| 655 |
\noexpand\catcode`\noexpand\;=\the\catcode`\;\noexpand\space |
| 656 |
\noexpand\catcode`\noexpand\:=\the\catcode`\:\noexpand\space |
| 657 |
\noexpand\catcode`\noexpand\%=\the\catcode`\%\noexpand\space |
| 658 |
\noexpand\catcode`\noexpand\^^I=\the\catcode`\^^I\noexpand\space |
| 659 |
\noexpand\let\noexpand\pgfplotstablereadrestorecatcodes=\noexpand\relax |
| 660 |
}% |
| 661 |
\ifcase\pgfplotstableread@FORMAT@CASE\relax |
| 662 |
% format=auto |
| 663 |
\pgfplotstablereadpreparecatcodes@ |
| 664 |
\or |
| 665 |
% format=inline |
| 666 |
\pgfplotstablereadpreparecatcodes@ |
| 667 |
\fi |
| 668 |
\fi |
| 669 |
} |
| 670 |
\let\pgfplotstablereadrestorecatcodes=\relax |
| 671 |
|
| 672 |
% ATTENTION: the following catcodes are ONLY useful for <inline tables>! |
| 673 |
% tables read from file need catcode adaptions as well; this is done |
| 674 |
% elsewhere! |
| 675 |
\def\pgfplotstablereadpreparecatcodes@{% |
| 676 |
\if0\pgfplotstableread@ROWSEP@CASE\relax |
| 677 |
% row sep = newline |
| 678 |
\catcode`\^^M=12 |
| 679 |
\fi |
| 680 |
\ifcase\pgfplotstableread@COLSEP@CASE\relax |
| 681 |
% col sep=space: |
| 682 |
\catcode`\ =10 |
| 683 |
\or |
| 684 |
% col sep=comma: |
| 685 |
\or |
| 686 |
% col sep=semicolon: |
| 687 |
\catcode`\;=12 |
| 688 |
\or |
| 689 |
% col sep=colon: |
| 690 |
\catcode`\:=12 |
| 691 |
\or |
| 692 |
% col sep=brace: |
| 693 |
\or |
| 694 |
% col sep=tab: |
| 695 |
\catcode`\^^I=12 |
| 696 |
\fi |
| 697 |
\pgfplotstableinstallignorechars |
| 698 |
}% |
| 699 |
|
| 700 |
% Logically, this routine does |
| 701 |
% \pgfplotstablereadpreparecatcodes |
| 702 |
% #1 |
| 703 |
% and that's all. However, It makes sure that any white space |
| 704 |
% characters (especially newlines) between '#1' and the following |
| 705 |
% argument are gobbled! |
| 706 |
% |
| 707 |
% To show the problem, consider |
| 708 |
% \pgfplotstabletypeset[<options>] |
| 709 |
% \loadedtable |
| 710 |
% |
| 711 |
% and we want to set the catcodes *before* \loadedtable is seen. |
| 712 |
% Well, there is a newline character after ']'! If we change the |
| 713 |
% catcodes, this newline will be considered as character and will make |
| 714 |
% up the first argument, the \loadedtable will be ignored. |
| 715 |
% |
| 716 |
% \pgfplotstablecollectoneargwithpreparecatcodes avoids this problem |
| 717 |
% by gobbling all space (newline) characters *before* collecting the |
| 718 |
% directly following argument token. Furthermore, it restores the |
| 719 |
% catcodes directly after the argument has been collected. |
| 720 |
% |
| 721 |
% @see \pgfplotstablecollectoneargwithpreparecatcodesnorestore |
| 722 |
\long\def\pgfplotstablecollectoneargwithpreparecatcodes#1{% |
| 723 |
\begingroup |
| 724 |
\t@pgfplotstable@a{{#1}}% this allows '#' characters in '#1' |
| 725 |
\def\pgfplotstablecollectoneargwithpreparecatcodes@@{% |
| 726 |
\pgfplotstablereadpreparecatcodes |
| 727 |
\expandafter\pgfplotstablecollectoneargwithpreparecatcodes@end\the\t@pgfplotstable@a% |
| 728 |
}% |
| 729 |
% equivalent to |
| 730 |
%\let\pgfplotstable@loc@TMPa=<next token>\pgfplotstablecollectoneargwithpreparecatcodes@@<next token> |
| 731 |
\futurelet\pgfplotstable@loc@TMPa\pgfplotstablecollectoneargwithpreparecatcodes@@ |
| 732 |
% this employs a side effect: \futurelet gobbles any spaces |
| 733 |
% (including newlines). |
| 734 |
}% |
| 735 |
\long\def\pgfplotstablecollectoneargwithpreparecatcodes@end#1#2{% |
| 736 |
\endgroup |
| 737 |
#1{#2}% |
| 738 |
}% |
| 739 |
|
| 740 |
% An overloaded method of |
| 741 |
% \pgfplotstablecollectoneargwithpreparecatcodes which does not |
| 742 |
% restore the catcodes after collecting one arg. |
| 743 |
\long\def\pgfplotstablecollectoneargwithpreparecatcodesnorestore#1{% |
| 744 |
\t@pgfplotstable@a{{#1}}% |
| 745 |
\def\pgfplotstablecollectoneargwithpreparecatcodes@@{% |
| 746 |
\expandafter\pgfplotstablereadpreparecatcodes\t@pgfplotstable@a |
| 747 |
}% |
| 748 |
% equivalent to |
| 749 |
%\let\pgfplotstable@loc@TMPa=<next token>\pgfplotstablecollectoneargwithpreparecatcodes@@<next token> |
| 750 |
\futurelet\pgfplotstable@loc@TMPa\pgfplotstablecollectoneargwithpreparecatcodes@@ |
| 751 |
}% |
| 752 |
|
| 753 |
% Accept one of |
| 754 |
% \pgfplotstableread[#1]{<file>}{<\macro>} |
| 755 |
% \pgfplotstableread[#1]{<file>} to listener{<\macro>} |
| 756 |
% or |
| 757 |
% \pgfplotstableread[#1]{<file>} to {<\macro>} (DEPRECATED) |
| 758 |
\long\def\pgfplotstableread@impl[#1]{% |
| 759 |
\ifpgfplots@tableread@use@begingroup |
| 760 |
\begingroup |
| 761 |
\def\endgroup@@pgfplotstableread{\endgroup}% |
| 762 |
\else |
| 763 |
\let\endgroup@@pgfplotstableread=\relax% |
| 764 |
\fi |
| 765 |
% set options here, although we can't evaluate 'every table' yet |
| 766 |
% (the file name is not yet known). |
| 767 |
% But #1 may contain input format specifiers which are important |
| 768 |
% for \catcodes, BEFORE we have read the second argument: |
| 769 |
\pgfplotstableset{#1}% |
| 770 |
% |
| 771 |
\pgfplotstablecollectoneargwithpreparecatcodes{% |
| 772 |
\pgfplotstableread@impl@collectfirstarg{#1}% |
| 773 |
}% |
| 774 |
}% |
| 775 |
\long\def\pgfplotstableread@impl@collectfirstarg#1#2{% |
| 776 |
\pgfplotsutil@ifnextchar t{% |
| 777 |
\pgfplotstableread@impl@@{#1}{#2}% |
| 778 |
}{% |
| 779 |
\pgfplotstableread@impl@{#1}{#2}% |
| 780 |
}% |
| 781 |
}% |
| 782 |
|
| 783 |
|
| 784 |
% I don't know why; but I started with |
| 785 |
% >> \pgfplotstableread[]{file} to \macro |
| 786 |
% That ' to ' is really ugly. This here is for backwards |
| 787 |
% compatibility: |
| 788 |
\long\def\pgfplotstableread@impl@@#1#2to {% |
| 789 |
\pgfutil@ifnextchar l{% |
| 790 |
\pgfplotstableread@impl@@listener{#1}{#2}% |
| 791 |
}{% |
| 792 |
\pgfplotstableread@impl@{#1}{#2}% |
| 793 |
}% |
| 794 |
}% |
| 795 |
\long\def\pgfplotstableread@impl@@listener#1#2listener#3{% |
| 796 |
\pgfplots@tableread@to@listenertrue |
| 797 |
\pgfplotstableread@impl@{#1}{#2}{#3}% |
| 798 |
\pgfplots@tableread@to@listenerfalse |
| 799 |
}% |
| 800 |
|
| 801 |
\newif\ifpgfplotstableread@inline |
| 802 |
\long\def\pgfplotstableread@checkinlineformat@CRCR#1\\#2\pgfplotstable@EOI{% |
| 803 |
\def\pgfplotstable@loc@TMPa{#2}% |
| 804 |
\ifx\pgfplotstable@loc@TMPa\pgfutil@empty |
| 805 |
\pgfplotstableread@inlinefalse |
| 806 |
\else |
| 807 |
\pgfplotstableread@inlinetrue |
| 808 |
\let\pgfplotstableread@loop@next=\pgfplotstableread@loop@next@CRCR |
| 809 |
\fi |
| 810 |
}% |
| 811 |
\long\def\pgfplotstableread@loop@next@CRCR#1\\{% |
| 812 |
\long\def\pgfplotstable@LINE{#1}% |
| 813 |
\pgfplotstableread@loop@processnextline |
| 814 |
\pgfplotstableread@loop@over@lines |
| 815 |
}% |
| 816 |
\begingroup |
| 817 |
\catcode`\^^M=12\relax% |
| 818 |
\gdef\pgfplotstableread@NL@other{^^M}% |
| 819 |
\long\gdef\pgfplotstableread@checkinlineformat@NL@#1^^M#2\pgfplotstable@EOI{% |
| 820 |
\def\pgfplotstable@loc@TMPa{#2}% |
| 821 |
\ifx\pgfplotstable@loc@TMPa\pgfutil@empty% |
| 822 |
\pgfplotstableread@inlinefalse% |
| 823 |
\else% |
| 824 |
\pgfplotstableread@inlinetrue% |
| 825 |
\let\pgfplotstableread@loop@next=\pgfplotstableread@loop@next@NL% |
| 826 |
\fi% |
| 827 |
}% |
| 828 |
\long\gdef\pgfplotstableread@checkinlineformat@NL#1{% |
| 829 |
\pgfplotstableread@checkinlineformat@NL@ #1^^M\pgfplotstable@EOI% |
| 830 |
}% |
| 831 |
\long\gdef\pgfplotstableread@loop@next@NL#1^^M{% |
| 832 |
\long\def\pgfplotstable@LINE{#1}% |
| 833 |
\pgfplotstableread@loop@processnextline% |
| 834 |
\pgfplotstableread@loop@over@lines% |
| 835 |
}% |
| 836 |
\endgroup |
| 837 |
|
| 838 |
% #1: options. |
| 839 |
% #2: the table content (file name or inline data) |
| 840 |
% #3: the result macro. |
| 841 |
\long\def\pgfplotstableread@impl@#1#2#3{% |
| 842 |
\ifcase\pgfplotstableread@FORMAT@CASE\relax |
| 843 |
% format=auto |
| 844 |
\ifcase\pgfplotstableread@ROWSEP@CASE\relax |
| 845 |
% row sep=newline |
| 846 |
\pgfplotstableread@checkinlineformat@NL{#2}% |
| 847 |
\or |
| 848 |
% row sep=crcr |
| 849 |
\pgfplotstableread@checkinlineformat@CRCR #2\\\pgfplotstable@EOI |
| 850 |
\fi |
| 851 |
\or |
| 852 |
% format=inline |
| 853 |
\pgfplotstableread@inlinetrue |
| 854 |
\ifcase\pgfplotstableread@ROWSEP@CASE\relax |
| 855 |
% row sep=newline |
| 856 |
\let\pgfplotstableread@loop@next=\pgfplotstableread@loop@next@NL |
| 857 |
\or |
| 858 |
% row sep=crcr |
| 859 |
\let\pgfplotstableread@loop@next=\pgfplotstableread@loop@next@CRCR |
| 860 |
\fi |
| 861 |
\or |
| 862 |
\pgfplotstableread@inlinefalse |
| 863 |
\fi |
| 864 |
% |
| 865 |
\ifpgfplotstableread@inline |
| 866 |
\else |
| 867 |
\if1\pgfplotstableread@ROWSEP@CASE |
| 868 |
% row sep=crcr |
| 869 |
\pgfplotsthrow{unsupported operation}{Sorry, the choice 'row sep=crcr' is currently only available for inline tables, not for external files}\pgfeov |
| 870 |
\fi |
| 871 |
\fi |
| 872 |
% |
| 873 |
% optimizations: |
| 874 |
\pgfkeysgetvalue{/pgfplots/table/comment chars}\pgfplots@loc@TMPd |
| 875 |
\ifx\pgfplots@loc@TMPd\pgfutil@empty |
| 876 |
\let\pgfplotstableread@checkspecial@line@default=\relax |
| 877 |
\fi |
| 878 |
\pgfkeysgetvalue{/pgfplots/table/skip first n}\pgfplots@loc@TMPd |
| 879 |
\ifx\pgfplots@loc@TMPd\pgfutil@empty \let\pgfplotstableread@check@skipfirstn=\relax \fi |
| 880 |
\ifnum\pgfplots@loc@TMPd=0 \let\pgfplotstableread@check@skipfirstn=\relax \fi |
| 881 |
% |
| 882 |
\ifpgfplotstableread@inline |
| 883 |
\def\pgfplotstableread@impl@fCLOSE{}% |
| 884 |
\let\pgfplotstableread@loop@over@lines=\pgfplotstableread@loop@over@lines@frominline% |
| 885 |
\long\def\pgfplotstableread@start@loop{% |
| 886 |
\pgfplotstableread@loop@over@lines #2\pgfplotstable@EOI |
| 887 |
}% |
| 888 |
\def\pgfplotstableread@ready{1}% |
| 889 |
\def\pgfplotstableread@filename{<inline_table>}% |
| 890 |
\else |
| 891 |
\def\pgfplotstableread@ready{1}% |
| 892 |
\def\pgfplotstableread@filename{#2}% |
| 893 |
\pgfplotstableread@openfile |
| 894 |
\def\pgfplotstableread@impl@fCLOSE{% |
| 895 |
\closein\r@pgfplots@reada |
| 896 |
}% |
| 897 |
\let\pgfplotstableread@loop@over@lines=\pgfplotstableread@loop@over@lines@fromfile% |
| 898 |
\def\pgfplotstableread@start@loop{\pgfplotstableread@loop@over@lines}% |
| 899 |
\pgfplotstableinstallignorechars |
| 900 |
\fi |
| 901 |
\edef\pgfplotstableread@oldendlinechar{\the\endlinechar}% |
| 902 |
\endlinechar=-1 % do not append a white space after each line for file input |
| 903 |
%\pgfplots@message{ATTEMPTING TO READ \pgfplotstableread@filename}% |
| 904 |
% |
| 905 |
\def\pgfplots@loc@TMPa{\pgfplotstableread@impl@prepare{#1}}% |
| 906 |
\expandafter\pgfplots@loc@TMPa\expandafter{\pgfplotstableread@filename}{#3}% |
| 907 |
% |
| 908 |
\if1\pgfplotstableread@ready |
| 909 |
\pgfplotstableread@start@loop |
| 910 |
% |
| 911 |
\pgfplotstableread@impl@fCLOSE% |
| 912 |
% |
| 913 |
\pgfplotstableread@finish |
| 914 |
% |
| 915 |
\fi |
| 916 |
\endlinechar=\pgfplotstableread@oldendlinechar |
| 917 |
\pgfplotsscanlinelengthcleanup |
| 918 |
\expandafter\pgfplotstable@copy@to@globalbuffers@simple\expandafter{\pgfplotstableread@filename}% |
| 919 |
\endgroup@@pgfplotstableread |
| 920 |
\ifpgfplots@tableread@to@listener |
| 921 |
% there are no data structures in this case. |
| 922 |
\let\pgfplotsscanlinelength=\pgfplotstable@glob@buf@scanline |
| 923 |
\else |
| 924 |
% Now, we can access the global variables! |
| 925 |
% copy them to #3. |
| 926 |
\pgfplotstable@copy@globalbuffers@to#3% |
| 927 |
\fi |
| 928 |
} |
| 929 |
|
| 930 |
{\catcode`\"=12 \gdef\pgfplots@dquote{"}} |
| 931 |
|
| 932 |
% gets the search path (after applying some basic sanity checks) |
| 933 |
\def\pgfplotstable@get@search@path{% |
| 934 |
\pgfkeysgetvalue{/pgfplots/table/search path}\pgfplotsretval |
| 935 |
\ifx\pgfplotsretval\pgfutil@empty |
| 936 |
\def\pgfplotsretval{.}% |
| 937 |
\pgfkeyslet{/pgfplots/table/search path}\pgfplotsretval |
| 938 |
\fi |
| 939 |
% |
| 940 |
\ifpgfplotstable@search@path@implicit@CWD |
| 941 |
\def\b@pgfplotstable@search@contains@cwd{0}% |
| 942 |
\def\pgfplotstable@loc@TMPd{.}% |
| 943 |
\def\pgfplotstable@loc@TMPc{./}% |
| 944 |
\expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotsretval}\as\pgfplotstable@loc@TMPa{% |
| 945 |
\ifx\pgfplotstable@loc@TMPa\pgfplotstable@loc@TMPd |
| 946 |
\def\b@pgfplotstable@search@contains@cwd{1}% |
| 947 |
\fi |
| 948 |
\ifx\pgfplotstable@loc@TMPa\pgfplotstable@loc@TMPc |
| 949 |
\def\b@pgfplotstable@search@contains@cwd{1}% |
| 950 |
\fi |
| 951 |
}% |
| 952 |
% |
| 953 |
\if0\b@pgfplotstable@search@contains@cwd |
| 954 |
\t@pgfplotstable@a=\expandafter{\pgfplotsretval}% |
| 955 |
\edef\pgfplotsretval{.,\the\t@pgfplotstable@a}% |
| 956 |
\pgfkeyslet{/pgfplots/table/search path}\pgfplotsretval |
| 957 |
\fi |
| 958 |
\fi |
| 959 |
} |
| 960 |
|
| 961 |
\def\pgfplotstable@search@path@add@slash#1{% |
| 962 |
\def\pgfplotsretval{#1/}% |
| 963 |
\def\pgfplotstable@loc@TMPd{./}% |
| 964 |
\def\pgfplotstable@loc@TMPc{.//}% |
| 965 |
\ifx\pgfplotsretval\pgfplotstable@loc@TMPd |
| 966 |
% Ah -- we have #1='.' Do NOT use a slash at all in order to |
| 967 |
% not disable the processing of TEXINPUTS (if pdftex finds ./ |
| 968 |
% , it will NOT evaluated TEXINPUTS as it seems) |
| 969 |
\let\pgfplotsretval=\pgfutil@empty |
| 970 |
\fi |
| 971 |
\ifx\pgfplotsretval\pgfplotstable@loc@TMPc |
| 972 |
\let\pgfplotsretval=\pgfutil@empty |
| 973 |
\fi |
| 974 |
}% |
| 975 |
|
| 976 |
% |
| 977 |
% POSTCONDITION: |
| 978 |
% - \r@pgfplots@reada is the opened result file (or eof if there is no |
| 979 |
% such file). |
| 980 |
% - \pgfplotstableread@filename is the first found file path. |
| 981 |
\def\pgfplotstable@search@and@open@file{% |
| 982 |
\pgfplotstable@get@search@path |
| 983 |
% |
| 984 |
\let\pgfplotstableread@filename@name=\pgfplotstableread@filename |
| 985 |
% |
| 986 |
\def\b@pgfplotstable@search@done{0}% |
| 987 |
\expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotsretval}\as\pgfplotstable@loc@TMPa{% |
| 988 |
\ifx\pgfplotstable@loc@TMPa\pgfutil@empty |
| 989 |
% silently skip empty entries in the list. |
| 990 |
\else |
| 991 |
\if0\b@pgfplotstable@search@done |
| 992 |
% |
| 993 |
\expandafter\pgfplotstable@search@path@add@slash\expandafter{\pgfplotstable@loc@TMPa}% |
| 994 |
% |
| 995 |
\t@pgfplotstable@a=\expandafter{\pgfplotsretval}% |
| 996 |
\t@pgfplots@tokc=\expandafter{\pgfplotstableread@filename@name}% |
| 997 |
\edef\pgfplotstableread@filename{\the\t@pgfplotstable@a\the\t@pgfplots@tokc}% |
| 998 |
% |
| 999 |
\openin\r@pgfplots@reada=\[email protected] |
| 1000 |
\ifeof\r@pgfplots@reada |
| 1001 |
\openin\r@pgfplots@reada=\pgfplotstableread@filename\relax |
| 1002 |
\else |
| 1003 |
\pgfplots@warning{% |
| 1004 |
You requested to open table '\pgfplotstableread@filename', but there is also a '\[email protected]'. |
| 1005 |
TeX will automatically append the suffix '.tex', so I will now open '\[email protected]'. |
| 1006 |
Please make sure you don't accidentally load TeX files - this may produce unrecoverable errors.}% |
| 1007 |
\closein\r@pgfplots@reada |
| 1008 |
\openin\r@pgfplots@reada=\pgfplotstableread@filename\relax |
| 1009 |
\fi |
| 1010 |
% |
| 1011 |
\ifeof\r@pgfplots@reada |
| 1012 |
\else |
| 1013 |
\def\b@pgfplotstable@search@done{1}% |
| 1014 |
\fi |
| 1015 |
\fi |
| 1016 |
\fi |
| 1017 |
}% |
| 1018 |
% |
| 1019 |
\if0\b@pgfplotstable@search@done |
| 1020 |
\let\pgfplotstableread@filename=\pgfplotstableread@filename@name |
| 1021 |
\fi |
| 1022 |
}% |
| 1023 |
|
| 1024 |
% Opens \pgfplotstableread@filename. |
| 1025 |
\def\pgfplotstableread@openfile{% |
| 1026 |
\def\pgfplotstable@loc@TMPa{\pgfutil@in@{ }}% |
| 1027 |
\expandafter\pgfplotstable@loc@TMPa\expandafter{\pgfplotstableread@filename}% |
| 1028 |
\ifpgfutil@in@ |
| 1029 |
\t@pgfplots@toka=\expandafter{\pgfplotstableread@filename}% |
| 1030 |
\edef\pgfplotstableread@filename{\pgfplots@dquote\the\t@pgfplots@toka\pgfplots@dquote}% |
| 1031 |
\fi |
| 1032 |
\let\pgfplotstableread@old@crcr=\\% |
| 1033 |
\def\\{\string\\}% just to make sure we don't try to open inline table data... |
| 1034 |
% |
| 1035 |
\pgfplotstable@search@and@open@file |
| 1036 |
% |
| 1037 |
\ifeof\r@pgfplots@reada |
| 1038 |
\pgfplotsthrow{no such table file}{\pgfplots@loc@TMPa}{\pgfplotstableread@filename}{Could not read table file '\pgfplotstableread@filename' in 'search path=\pgfkeysvalueof{/pgfplots/table/search path}'. In case you intended to provide inline data: maybe TeX screwed up your end-of-lines? Try `row sep=crcr' and terminate your lines with `\string\\' (refer to the pgfplotstable manual for details)}\pgfeov% |
| 1039 |
\global\let\pgfplotstable@colnames@glob=\pgfplots@loc@TMPa |
| 1040 |
\def\pgfplotstableread@ready{0}% |
| 1041 |
\fi |
| 1042 |
\pgfplots@logfileopen{\pgfplotstableread@filename}% |
| 1043 |
\let\\=\pgfplotstableread@old@crcr |
| 1044 |
} |
| 1045 |
|
| 1046 |
\def\pgfplotstableinstallignorechars{% |
| 1047 |
\ifx\pgfplotstableuninstallignorechars\pgfutil@empty |
| 1048 |
\pgfkeysgetvalue{/pgfplots/table/ignore chars}\pgfplotstable@loc@TMPa |
| 1049 |
\ifx\pgfplotstable@loc@TMPa\pgfutil@empty |
| 1050 |
\else |
| 1051 |
\pgfplotstableinstallignorechars@\pgfplotstable@loc@TMPa{9}% |
| 1052 |
\fi |
| 1053 |
\pgfkeysgetvalue{/pgfplots/table/white space chars}\pgfplotstable@loc@TMPa |
| 1054 |
\ifx\pgfplotstable@loc@TMPa\pgfutil@empty |
| 1055 |
\else |
| 1056 |
\pgfplotstableinstallignorechars@\pgfplotstable@loc@TMPa{10}% |
| 1057 |
\fi |
| 1058 |
\pgfkeysgetvalue{/pgfplots/table/text special chars}\pgfplotstable@loc@TMPa |
| 1059 |
\ifx\pgfplotstable@loc@TMPa\pgfutil@empty |
| 1060 |
\else |
| 1061 |
\pgfplotstableinstallignorechars@\pgfplotstable@loc@TMPa{12}% |
| 1062 |
\fi |
| 1063 |
\ifpgfplotstable@percent@is@letter |
| 1064 |
\def\pgfplotstable@loc@TMPa{\%}% |
| 1065 |
\pgfplotstableinstallignorechars@\pgfplotstable@loc@TMPa{12}% |
| 1066 |
\fi |
| 1067 |
\ifx\pgfplotstableuninstallignorechars\pgfutil@empty |
| 1068 |
\else |
| 1069 |
\expandafter\def\expandafter\pgfplotstableuninstallignorechars\expandafter{% |
| 1070 |
\pgfplotstableuninstallignorechars |
| 1071 |
\let\pgfplotstableuninstallignorechars=\pgfutil@empty |
| 1072 |
}% |
| 1073 |
\fi |
| 1074 |
\fi |
| 1075 |
}% |
| 1076 |
\let\pgfplotstableuninstallignorechars\pgfutil@empty% |
| 1077 |
% #1 macro containing the characters as comma-separated list |
| 1078 |
% #2 the catcode to assign |
| 1079 |
\def\pgfplotstableinstallignorechars@#1#2{% |
| 1080 |
\expandafter\pgfplotsutilforeachcommasep\expandafter{#1}\as\pgfplotstable@loc@TMPa{% |
| 1081 |
\t@pgfplots@toka=\expandafter{\pgfplotstableuninstallignorechars}% |
| 1082 |
\edef\pgfplotstableuninstallignorechars{% |
| 1083 |
\the\t@pgfplots@toka |
| 1084 |
\noexpand\catcode`\expandafter\noexpand\pgfplotstable@loc@TMPa=\expandafter\the\expandafter\catcode\expandafter`\pgfplotstable@loc@TMPa\noexpand\space |
| 1085 |
}% |
| 1086 |
\expandafter\catcode\expandafter`\pgfplotstable@loc@TMPa=#2\relax |
| 1087 |
}% |
| 1088 |
}% |
| 1089 |
|
| 1090 |
% #1: any options to set (respect \ifpgfplots@table@options@areset ) |
| 1091 |
% #2: the file name (if any) |
| 1092 |
% #3: the output macro (or listener) |
| 1093 |
\def\pgfplotstableread@impl@prepare#1#2#3{% |
| 1094 |
\ifpgfplots@table@options@areset |
| 1095 |
\else |
| 1096 |
\pgfplotstableset@every@table{#2}{#1}% |
| 1097 |
\fi |
| 1098 |
% |
| 1099 |
\def\pgfplotstablename{\pgfplotstable@colnames@glob}% provide the name of the actual table struct (during \pgfplotstableread, only partial functionality is available!) |
| 1100 |
% |
| 1101 |
% local counter definitions: |
| 1102 |
\ifpgfplots@tableread@use@begingroup |
| 1103 |
\let\pgfplotstableread@lineno=\c@pgf@counta |
| 1104 |
\let\pgfplotstableread@numcols=\c@pgf@countb |
| 1105 |
\let\pgfplotstableread@curcol=\c@pgf@countc |
| 1106 |
\let\pgfplotstableread@usablelineno=\c@pgf@countd |
| 1107 |
\def\thepgfplotstableread@lineno{\the\pgfplotstableread@lineno}% |
| 1108 |
\def\thepgfplotstableread@usablelineno{\the\pgfplotstableread@usablelineno}% |
| 1109 |
\def\thepgfplotstableread@curcol{\the\pgfplotstableread@curcol}% |
| 1110 |
\def\thepgfplotstableread@numcols{\the\pgfplotstableread@numcols}% |
| 1111 |
\def\pgfplotstableread@countreset##1{##1=0 }% |
| 1112 |
\def\pgfplotstableread@countset##1##2{##1=##2\relax}% |
| 1113 |
\def\pgfplotstableread@countadvance##1{\advance##1 by1 }% |
| 1114 |
\else |
| 1115 |
% don't re-use integers! We have no protecting scopes! |
| 1116 |
\def\thepgfplotstableread@lineno{\pgfplotstableread@lineno}% |
| 1117 |
\def\thepgfplotstableread@usablelineno{\pgfplotstableread@usablelineno}% |
| 1118 |
\def\thepgfplotstableread@curcol{\pgfplotstableread@curcol}% |
| 1119 |
\def\thepgfplotstableread@numcols{\pgfplotstableread@numcols}% |
| 1120 |
\def\pgfplotstableread@countreset##1{\def##1{0}}% |
| 1121 |
\def\pgfplotstableread@countset##1##2{\def##1{##2}}% |
| 1122 |
\def\pgfplotstableread@countadvance##1{\pgfplotsutil@advancestringcounter{##1}}% |
| 1123 |
\fi |
| 1124 |
\pgfplotstableread@countreset\pgfplotstableread@lineno |
| 1125 |
\pgfplotstableread@countreset\pgfplotstableread@usablelineno |
| 1126 |
\pgfplotstableread@countreset\pgfplotstableread@numcols |
| 1127 |
\pgfplotstableread@countreset\pgfplotstableread@curcol |
| 1128 |
% |
| 1129 |
\pgfplotstableread@impl@prepare@DO |
| 1130 |
\pgfplotstableread@impl@prepare@DO@textindicator |
| 1131 |
% |
| 1132 |
\def\pgfplotstableread@isgnuplotformat{0}% |
| 1133 |
\global\pgfplotslistnewempty\pgfplotstable@colnames@glob |
| 1134 |
\pgfplotsscanlinelengthinitzero |
| 1135 |
\ifpgfplots@tableread@to@listener |
| 1136 |
\def\pgfplotstablerow{\thepgfplotstableread@usablelineno}% |
| 1137 |
\def\pgfplotstablelineno{\thepgfplotstableread@lineno}% |
| 1138 |
\let\pgfplotstable@listener=#3% |
| 1139 |
\let\pgfplotstableread@impl@nextrow@NEXT=\pgfplotstableread@impl@nextrow@NEXT@listener |
| 1140 |
\let\pgfplotstablereadgetcolindex=\pgfplotstablereadgetcolindex@ |
| 1141 |
\let\pgfplotstablereadgetcolname=\pgfplotstablereadgetcolname@ |
| 1142 |
\let\pgfplotstablereadgetptrtocolname=\pgfplotstablereadgetptrtocolname@ |
| 1143 |
\let\pgfplotstablereadgetptrtocolindex=\pgfplotstablereadgetptrtocolindex@ |
| 1144 |
\let\pgfplotstablereadevalptr=\pgfplotstablereadevalptr@ |
| 1145 |
\let\pgfplotstablereadvalueofptr=\pgfplotstablereadvalueofptr@ |
| 1146 |
\let\pgfplotstableforeachcolumn=\pgfplotstableforeachcolumn@listener |
| 1147 |
\let\pgfplotstablereadvalueofcolname=\pgfplotstablereadvalueofcolname@ |
| 1148 |
\let\pgfplotstablereadvalueofcolindex=\pgfplotstablereadvalueofcolindex@ |
| 1149 |
\let\getthisrow=\pgfplotstablereadgetcolname |
| 1150 |
\let\thisrow=\pgfplotstablereadvalueofcolname |
| 1151 |
\let\thisrowno=\pgfplotstablereadvalueofcolindex |
| 1152 |
\let\getthisrowno=\pgfplotstablereadgetcolindex |
| 1153 |
\fi |
| 1154 |
}% |
| 1155 |
|
| 1156 |
% Copies the table column list and the column vectors of #1 to global buffers. |
| 1157 |
% @see \pgfplotstable@copy@globalbuffers@to |
| 1158 |
% |
| 1159 |
% Use these two methods to avoid scoping problems. |
| 1160 |
% |
| 1161 |
% #1: the <\macro> name of the table which is to be copied to global buffers. |
| 1162 |
% #2: the table file name. |
| 1163 |
\def\pgfplotstable@copy@to@globalbuffers#1#2{% |
| 1164 |
\global\let\pgfplotstable@colnames@glob=#1\relax |
| 1165 |
\c@pgfplotstable@counta=0\relax% |
| 1166 |
\pgfplotslistforeachungrouped\pgfplotstable@colnames@glob\as\pgfplotstable@loc@TMPa{% |
| 1167 |
\def\pgfplotstable@loc@TMPb{% |
| 1168 |
\expandafter\global\expandafter\let\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname% |
| 1169 |
}% |
| 1170 |
\expandafter\pgfplotstable@loc@TMPb\csname\string#1@\pgfplotstable@loc@TMPa\endcsname |
| 1171 |
\advance\c@pgfplotstable@counta by1\relax |
| 1172 |
}% |
| 1173 |
\pgfplotstable@copy@to@globalbuffers@simple{#2}% |
| 1174 |
}% |
| 1175 |
% A variant of \pgfplotstable@copy@to@globalbuffers which copies only |
| 1176 |
% the member variables of a loaded table (the name and scanline length) to |
| 1177 |
% global buffers. |
| 1178 |
% |
| 1179 |
% #1: the table's file name. |
| 1180 |
% |
| 1181 |
% @PRECONDITION: any other variables and cell data of the table are already stored |
| 1182 |
% in global buffers. |
| 1183 |
\def\pgfplotstable@copy@to@globalbuffers@simple#1{% |
| 1184 |
\gdef\pgfplotstable@glob@buf@name{#1}% |
| 1185 |
\global\let\pgfplotstable@glob@buf@scanline=\pgfplotsscanlinelength |
| 1186 |
}% |
| 1187 |
|
| 1188 |
% copies the global column list and the global column vectors to #1 |
| 1189 |
% (NOT the table file name). |
| 1190 |
% @see \pgfplotstable@copy@to@globalbuffers |
| 1191 |
% |
| 1192 |
% @PRECONDITION the global buffers contain all members of a table. |
| 1193 |
% |
| 1194 |
% @POSTCONDITION The table '#1' is be initialised to these members. |
| 1195 |
% Furthermore, \pgfplotsscanlinelength is set. |
| 1196 |
\def\pgfplotstable@copy@globalbuffers@to#1{% |
| 1197 |
\let#1=\pgfplotstable@colnames@glob |
| 1198 |
\c@pgfplotstable@counta=0\relax% |
| 1199 |
\pgfplotslistforeachungrouped\pgfplotstable@colnames@glob\as\pgfplotstable@loc@TMPa{% |
| 1200 |
\def\pgfplotstable@loc@TMPb{% |
| 1201 |
\expandafter\let\csname\string#1@\pgfplotstable@loc@TMPa\endcsname}% |
| 1202 |
\expandafter\pgfplotstable@loc@TMPb\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname |
| 1203 |
%\message{Column '\pgfplotstable@loc@TMPa' has entries: \expandafter\meaning\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname}% |
| 1204 |
\expandafter\global\expandafter\let\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname=\pgfutil@empty |
| 1205 |
\advance\c@pgfplotstable@counta by1\relax |
| 1206 |
}% |
| 1207 |
\global\let\pgfplotstable@colnames@glob=\pgfutil@empty |
| 1208 |
\expandafter\let\csname\string#1@@table@scanline\endcsname=\pgfplotstable@glob@buf@scanline |
| 1209 |
\expandafter\let\csname\string#1@@table@name\endcsname=\pgfplotstable@glob@buf@name |
| 1210 |
\let\pgfplotsscanlinelength=\pgfplotstable@glob@buf@scanline |
| 1211 |
}% |
| 1212 |
|
| 1213 |
\def\pgfplotstableread@finish{% |
| 1214 |
\pgfplotsscanlinecomplete |
| 1215 |
\ifpgfplots@tableread@to@listener |
| 1216 |
\else |
| 1217 |
\ifpgfplotstableread@foundcolnames |
| 1218 |
\else |
| 1219 |
\pgfplotstableread@create@column@names@with@numbers |
| 1220 |
\fi |
| 1221 |
\pgfplotstableread@countreset\pgfplotstableread@curcol% |
| 1222 |
\pgfutil@loop |
| 1223 |
\ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax |
| 1224 |
\expandafter\pgfplotsapplistXflushbuffers\csname pgfp@numtable@glob@col@\thepgfplotstableread@curcol\endcsname |
| 1225 |
\pgfplotstableread@countadvance\pgfplotstableread@curcol |
| 1226 |
\pgfutil@repeat |
| 1227 |
\fi |
| 1228 |
} |
| 1229 |
|
| 1230 |
\def\pgfplotstableread@loop@over@lines@fromfile{% |
| 1231 |
\ifeof\r@pgfplots@reada |
| 1232 |
%\pgfplots@message{EOF}% |
| 1233 |
\else |
| 1234 |
\read\r@pgfplots@reada to\pgfplotstable@LINE |
| 1235 |
%\message{read with \the\catcode`\%: \meaning\pgfplotstable@LINE^^J}% |
| 1236 |
\ifeof\r@pgfplots@reada |
| 1237 |
\else |
| 1238 |
\pgfplotstableread@loop@processnextline |
| 1239 |
\fi |
| 1240 |
\expandafter\pgfplotstableread@loop@over@lines |
| 1241 |
\fi |
| 1242 |
}% |
| 1243 |
\def\pgfplotstableread@loop@over@lines@frominline{% |
| 1244 |
\pgfutil@ifnextchar\pgfplotstable@EOI{% |
| 1245 |
\pgfutil@gobble |
| 1246 |
}{% |
| 1247 |
\pgfplotstableread@loop@next |
| 1248 |
}% |
| 1249 |
}% |
| 1250 |
|
| 1251 |
\def\pgfplotstableread@check@skipfirstn{% |
| 1252 |
\ifnum\pgfplotstableread@lineno<\pgfkeysvalueof{/pgfplots/table/skip first n} % |
| 1253 |
\pgfplotstableread@skiplinetrue |
| 1254 |
\fi |
| 1255 |
}% |
| 1256 |
|
| 1257 |
% PRECONDITION: |
| 1258 |
% \pgfplotstable@LINE contains the current input line. |
| 1259 |
\def\pgfplotstableread@loop@processnextline{% |
| 1260 |
\expandafter\pgfplotstableread@checkspecial@line\pgfplotstable@LINE\pgfplotstable@EOI |
| 1261 |
\pgfplotstableread@check@skipfirstn |
| 1262 |
\ifpgfplotstableread@skipline |
| 1263 |
\def\pgfplotstableread@gnuplotcheck{####x y type}% |
| 1264 |
\ifx\pgfplotstableread@gnuplotcheck\pgfplotstable@LINE |
| 1265 |
\def\pgfplotstableread@isgnuplotformat{1}% |
| 1266 |
\fi |
| 1267 |
\def\pgfplotstableread@gnuplotcheck{####x y z type}% |
| 1268 |
\ifx\pgfplotstableread@gnuplotcheck\pgfplotstable@LINE |
| 1269 |
\def\pgfplotstableread@isgnuplotformat{1}% |
| 1270 |
\fi |
| 1271 |
\else |
| 1272 |
%-------------------------------------------------- |
| 1273 |
% \ifnum\pgfplotstableread@lineno=0 |
| 1274 |
% \let\pgfplotstable@firstline=\pgfplotstable@LINE |
| 1275 |
% \fi |
| 1276 |
%-------------------------------------------------- |
| 1277 |
%\pgfplots@message{READING LINE \thepgfplotstableread@lineno: '\meaning\pgfplotstable@LINE'.}% |
| 1278 |
\pgfplotstableread@curline@contains@colnamesfalse |
| 1279 |
\ifnum\pgfplotstableread@numcols=0\relax |
| 1280 |
% STEP 0: initialise |
| 1281 |
% - count columns |
| 1282 |
% - find header data |
| 1283 |
\pgfplotstableread@countreset\pgfplotstableread@curcol |
| 1284 |
\ifpgfplotstable@firstline@is@header |
| 1285 |
\pgfplotstableread@curline@contains@colnamestrue |
| 1286 |
\fi |
| 1287 |
\pgfplotstableread@impl@DO\pgfplotstableread@impl@countcols@and@identifynames@NEXT\pgfplotstable@LINE |
| 1288 |
\pgfplotstableread@countset\pgfplotstableread@numcols{\pgfplotstableread@curcol}% |
| 1289 |
\edef\pgfplotstablecols{\thepgfplotstableread@numcols}% |
| 1290 |
\pgfplotstableread@countreset\pgfplotstableread@curcol |
| 1291 |
% Create empty column lists: |
| 1292 |
\pgfplotstableread@create@column@lists |
| 1293 |
% |
| 1294 |
\ifnum\pgfplotstableread@usablelineno=0\relax |
| 1295 |
\if1\pgfplotstableread@isgnuplotformat% |
| 1296 |
% The file started with |
| 1297 |
% #... |
| 1298 |
% #x y type |
| 1299 |
% X Y i |
| 1300 |
% -> thats a gnuplot file! |
| 1301 |
\pgfplotstableread@curline@contains@colnamesfalse |
| 1302 |
\fi |
| 1303 |
\fi |
| 1304 |
% Now, read the first line. |
| 1305 |
% It contains either |
| 1306 |
% - column names, |
| 1307 |
% - numerical data, |
| 1308 |
% - nothing (comments). |
| 1309 |
\ifpgfplotstableread@curline@contains@colnames |
| 1310 |
\pgfplotstableread@foundcolnamestrue |
| 1311 |
\pgfplotstableread@countreset\pgfplotstableread@curcol |
| 1312 |
\pgfplotstableread@impl@DO\pgfplotstableread@impl@collectcolnames@NEXT\pgfplotstable@LINE |
| 1313 |
\else |
| 1314 |
\pgfplotsscanlinelengthincrease |
| 1315 |
\pgfplotstableread@foundcolnamesfalse |
| 1316 |
\pgfplotstableread@countreset\pgfplotstableread@curcol |
| 1317 |
% Leave column name lists empty... |
| 1318 |
\pgfplotstableread@impl@DO\pgfplotstableread@impl@nextrow@NEXT\pgfplotstable@LINE |
| 1319 |
\fi |
| 1320 |
%\pgfplots@message{After reading first row: found '\thepgfplotstableread@numcols' columns; column name list='\meaning\pgfplotstable@colnames@glob'}% |
| 1321 |
\else |
| 1322 |
\pgfplotsscanlinelengthincrease |
| 1323 |
\pgfplotstableread@countreset\pgfplotstableread@curcol |
| 1324 |
\pgfplotstableread@impl@DO\pgfplotstableread@impl@nextrow@NEXT\pgfplotstable@LINE |
| 1325 |
\fi |
| 1326 |
\ifnum\pgfplotstableread@curcol=\pgfplotstableread@numcols\relax |
| 1327 |
\else |
| 1328 |
\begingroup |
| 1329 |
\t@pgfplots@tokc=\expandafter{\pgfplotstable@LINE}% |
| 1330 |
\pgfplotsthrow{table columns unbalanced}{input table '\pgfplotstableread@filename' has an unbalanced number of columns in row '\thepgfplotstableread@lineno' (expected '\thepgfplotstableread@numcols' cols; got '\thepgfplotstableread@curcol'). Maybe the input table is corrupted? If you need unbalanced data, consider using 'nan' in empty cells (perhaps combined with 'unbounded coords=jump'). The offending line is \the\t@pgfplots@tokc}\pgfeov% |
| 1331 |
\endgroup |
| 1332 |
\fi |
| 1333 |
\ifpgfplots@tableread@to@listener |
| 1334 |
\ifpgfplotstableread@curline@contains@colnames |
| 1335 |
\else |
| 1336 |
% report row! |
| 1337 |
\pgfplotstable@listener |
| 1338 |
\fi |
| 1339 |
\fi |
| 1340 |
\pgfplotstableread@countadvance\pgfplotstableread@usablelineno |
| 1341 |
\fi |
| 1342 |
\pgfplotstableread@countadvance\pgfplotstableread@lineno |
| 1343 |
}% |
| 1344 |
|
| 1345 |
% WARNING: this routine is also used in pgfplots.code.tex ... |
| 1346 |
\def\pgfplotstableread@checkspecial@line{% |
| 1347 |
\futurelet\pgfplotstableread@tmp\pgfplotstableread@checkspecial@line@ |
| 1348 |
}% |
| 1349 |
\def\pgfplotstableread@checkspecial@line@{% |
| 1350 |
\pgfplotstableread@skiplinefalse |
| 1351 |
\let\pgfplotstableread@checkspecial@line@@\pgfplotstableread@impl@gobble% |
| 1352 |
% |
| 1353 |
\let\pgfplotstableread@tmpb=##% |
| 1354 |
\ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb |
| 1355 |
\pgfplotstableread@skiplinetrue |
| 1356 |
\else |
| 1357 |
\let\pgfplotstableread@tmpb=$%$ |
| 1358 |
\ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb |
| 1359 |
\pgfplots@warning{Ignoring flags line... not implemented}% |
| 1360 |
\pgfplotstableread@skiplinetrue |
| 1361 |
\pgfplotsscanlinecomplete% the line is empty; same as \par! |
| 1362 |
\else |
| 1363 |
\let\pgfplotstableread@tmpb=\pgfplotstable@EOI% |
| 1364 |
\ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb |
| 1365 |
\pgfplotstableread@skiplinetrue |
| 1366 |
\pgfplotsscanlinecomplete% the line is empty; same as \par! |
| 1367 |
\else |
| 1368 |
\let\pgfplotstableread@tmpb=\par% |
| 1369 |
\ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb |
| 1370 |
\pgfplotstableread@skiplinetrue |
| 1371 |
\pgfplotsscanlinecomplete% the line is empty; |
| 1372 |
\else |
| 1373 |
\pgfplotstableread@checkspecial@line@default% |
| 1374 |
\fi |
| 1375 |
\fi |
| 1376 |
\fi |
| 1377 |
\fi |
| 1378 |
\pgfplotstableread@checkspecial@line@@ |
| 1379 |
}% |
| 1380 |
\def\pgfplotstableread@checkspecial@line@default{% |
| 1381 |
% this routine can be optimized away |
| 1382 |
\pgfkeysgetvalue{/pgfplots/table/comment chars}\pgfplots@loc@TMPd |
| 1383 |
\ifx\pgfplots@loc@TMPd\pgfutil@empty |
| 1384 |
\else |
| 1385 |
\expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplots@loc@TMPd}\as\pgfplots@loc@TMPd{% |
| 1386 |
\expandafter\let\expandafter\pgfplotstableread@tmpb\pgfplots@loc@TMPd |
| 1387 |
\ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb |
| 1388 |
\pgfplotstableread@skiplinetrue |
| 1389 |
\fi |
| 1390 |
}% |
| 1391 |
\fi |
| 1392 |
}% |
| 1393 |
|
| 1394 |
%-------------------------------------------------- |
| 1395 |
% \def\pgfplotstableread@checkspecial@line{% |
| 1396 |
% \pgfutil@ifnextchar##{% |
| 1397 |
% \pgfplotstableread@skiplinetrue |
| 1398 |
% \pgfplotstableread@impl@gobble |
| 1399 |
% }{% |
| 1400 |
% \pgfutil@ifnextchar${% |
| 1401 |
% \pgfplotstableread@process@flags@line |
| 1402 |
% }{% |
| 1403 |
% \pgfutil@ifnextchar\pgfplotstable@EOI{% |
| 1404 |
% \pgfplotstableread@skiplinetrue |
| 1405 |
% \pgfplotsscanlinecomplete% the line is empty; same as \par! |
| 1406 |
% \pgfplotstableread@impl@gobble |
| 1407 |
% }{% |
| 1408 |
% \pgfutil@ifnextchar\par{% |
| 1409 |
% \pgfplotstableread@skiplinetrue |
| 1410 |
% \pgfplotsscanlinecomplete |
| 1411 |
% \pgfplotstableread@impl@gobble |
| 1412 |
% }{% |
| 1413 |
% \pgfplotstableread@skiplinefalse |
| 1414 |
% \pgfplotstableread@impl@gobble |
| 1415 |
% }% |
| 1416 |
% }% |
| 1417 |
% }% |
| 1418 |
% }% |
| 1419 |
% } |
| 1420 |
%-------------------------------------------------- |
| 1421 |
|
| 1422 |
\def\pgfplotstableread@create@column@lists{% |
| 1423 |
\pgfutil@loop |
| 1424 |
\ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax |
| 1425 |
\def\pgfplots@loc@TMPa{\pgfplotsapplistXnewempty[to global]}% |
| 1426 |
\expandafter\pgfplots@loc@TMPa\csname pgfp@numtable@glob@col@\thepgfplotstableread@curcol\endcsname |
| 1427 |
\pgfplotstableread@countadvance\pgfplotstableread@curcol |
| 1428 |
\pgfutil@repeat |
| 1429 |
} |
| 1430 |
|
| 1431 |
\def\pgfplotstableread@create@column@names@with@numbers{% |
| 1432 |
\pgfplotstableread@countreset\pgfplotstableread@curcol |
| 1433 |
\pgfutil@loop |
| 1434 |
\ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax |
| 1435 |
\edef\pgfplotstable@loc@TMPb{\thepgfplotstableread@curcol}% |
| 1436 |
\expandafter\pgfplotslistpushbackglobal\pgfplotstable@loc@TMPb\to\pgfplotstable@colnames@glob |
| 1437 |
\pgfplotstableread@countadvance\pgfplotstableread@curcol |
| 1438 |
\pgfutil@repeat |
| 1439 |
} |
| 1440 |
|
| 1441 |
\long\def\pgfplotstableread@impl@gobble#1\pgfplotstable@EOI{}% |
| 1442 |
|
| 1443 |
\def\pgfplotstable@EOI{\pgfplotstable@EOI}% |
| 1444 |
|
| 1445 |
% A loop command which processes every single entry in a raw data row #2 |
| 1446 |
% and invokes the macro #1{<arg>} for each found column entry. |
| 1447 |
% |
| 1448 |
% Columns are separated by the /pgfplots/table/col sep character. |
| 1449 |
% |
| 1450 |
% #1: a command which takes precisely one argument. It will be called |
| 1451 |
% for each found column entry |
| 1452 |
% |
| 1453 |
% #2: a macro containing a raw data line with <col sep> separated |
| 1454 |
% entries. |
| 1455 |
\long\def\pgfplotstableread@impl@DO#1#2{% |
| 1456 |
\ifpgfplotstable@trimcells |
| 1457 |
\long\def\pgfplotstableread@impl@ITERATE@NEXT@##1{% |
| 1458 |
\pgfkeys@spdef\pgfplotstableread@impl@ITERATE@NEXT@@@{##1}% |
| 1459 |
\expandafter#1\expandafter{\pgfplotstableread@impl@ITERATE@NEXT@@@}% |
| 1460 |
}% |
| 1461 |
\else |
| 1462 |
\let\pgfplotstableread@impl@ITERATE@NEXT@=#1\relax |
| 1463 |
\fi |
| 1464 |
% |
| 1465 |
\expandafter\pgfplotstableread@impl@DO@\expandafter{#2}% |
| 1466 |
} |
| 1467 |
|
| 1468 |
{% |
| 1469 |
\catcode`\ =10 |
| 1470 |
\catcode`\;=12 |
| 1471 |
\catcode`\:=12 |
| 1472 |
\gdef\pgfplotstableread@impl@prepare@DO{% |
| 1473 |
\ifcase\pgfplotstableread@COLSEP@CASE\relax |
| 1474 |
% col sep=space: |
| 1475 |
\catcode`\ =10 |
| 1476 |
\long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1 \pgfplotstable@EOI}% |
| 1477 |
\or |
| 1478 |
% col sep=comma: |
| 1479 |
\let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@COMMA |
| 1480 |
\long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1,\pgfplotstable@EOI}% |
| 1481 |
\or |
| 1482 |
% col sep=semicolon: |
| 1483 |
\catcode`\;=12 |
| 1484 |
\let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@SEMICOLON |
| 1485 |
\long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1;\pgfplotstable@EOI}% |
| 1486 |
\or |
| 1487 |
% col sep=colon: |
| 1488 |
\catcode`\:=12 |
| 1489 |
\let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@COLON |
| 1490 |
\long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1:\pgfplotstable@EOI}% |
| 1491 |
\or |
| 1492 |
% col sep=brace: |
| 1493 |
% allow multi line cells: |
| 1494 |
\endlinechar=\pgfplotstableread@oldendlinechar\relax |
| 1495 |
\let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@BRACE |
| 1496 |
\long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1\pgfplotstable@EOI}% |
| 1497 |
\or |
| 1498 |
% col sep=tab: |
| 1499 |
\catcode`\^^I=12 |
| 1500 |
\let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@TAB |
| 1501 |
\long\edef\pgfplotstableread@impl@DO@##1{\noexpand\pgfplotstableread@impl@ITERATE##1\pgfplotstableread@tab\noexpand\pgfplotstable@EOI}% |
| 1502 |
\or |
| 1503 |
% col sep=&: |
| 1504 |
\let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@AMPERSAND |
| 1505 |
\long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1&\pgfplotstable@EOI}% |
| 1506 |
\fi |
| 1507 |
}% |
| 1508 |
}% |
| 1509 |
\def\pgfplotstableread@impl@prepare@DO@textindicator{% |
| 1510 |
% |
| 1511 |
\pgfkeysgetvalue{/pgfplots/table/text indicator}\pgfplots@loc@TMPa |
| 1512 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 1513 |
% ok, nothing special. |
| 1514 |
\else |
| 1515 |
% protect the text indicator such that it won't be expanded: |
| 1516 |
\t@pgfplots@tokc=\expandafter{\pgfplots@loc@TMPa}% |
| 1517 |
% |
| 1518 |
% compile macros which handle 'text indicator': |
| 1519 |
\let\pgfplotstableread@impl@ITERATE@NEXT@aftertextindicator=\pgfplotstableread@impl@ITERATE@NEXT |
| 1520 |
\edef\pgfplotstableread@impl@ITERATE@NEXT{% |
| 1521 |
% check if the cell starts with a text indicator: |
| 1522 |
\noexpand\pgfplotstableread@impl@ITERATE@NEXT@checkindicator{\the\t@pgfplots@tokc}% |
| 1523 |
}% |
| 1524 |
\edef\pgfplots@loc@TMPb{% |
| 1525 |
% compile this macro which reads everything up to the next |
| 1526 |
% text indicator char: |
| 1527 |
\noexpand\def\noexpand\pgfplotstableread@impl@ITERATE@NEXT@collect@text####1\the\t@pgfplots@tokc{% |
| 1528 |
% append. we assume that 'tokc' has been reset before |
| 1529 |
% starting to collect the cell content. |
| 1530 |
\t@pgfplots@tokc=\noexpand\expandafter{\noexpand\the\t@pgfplots@tokc####1}% |
| 1531 |
\noexpand\pgfutil@ifnextchar{\the\t@pgfplots@tokc}{% |
| 1532 |
% ah - a doubled text indicator. gobble this one |
| 1533 |
% and collect the following one! |
| 1534 |
\noexpand\pgfplotstableread@impl@ITERATE@NEXT@collect@text@collect@one |
| 1535 |
}{% |
| 1536 |
% ok, we found the entire cell content. |
| 1537 |
\noexpand\pgfplotstableread@impl@ITERATE@NEXT@collect@text@finish |
| 1538 |
}% |
| 1539 |
}% |
| 1540 |
}% |
| 1541 |
\pgfplots@loc@TMPb |
| 1542 |
% |
| 1543 |
\ifcase\pgfplotstableread@COLSEP@CASE\relax |
| 1544 |
\let\pgfplotstableread@impl@ITERATE@NEXT@collect@text@finish=\pgfplotstableread@impl@ITERATE@NEXT@collect@text@finish@APPENDSPACE |
| 1545 |
\fi |
| 1546 |
\fi |
| 1547 |
} |
| 1548 |
|
| 1549 |
\def\pgfplotstableread@impl@ITERATE@NEXT@collect@text@collect@one#1{% |
| 1550 |
\t@pgfplots@tokc=\expandafter{\the\t@pgfplots@tokc#1}% |
| 1551 |
\pgfplotstableread@impl@ITERATE@NEXT@collect@text |
| 1552 |
}% |
| 1553 |
\def\pgfplotstableread@impl@ITERATE@NEXT@collect@text@finish{% |
| 1554 |
% enclose the collected items into curly braces. This suppresses |
| 1555 |
% interpretation of extra chars: |
| 1556 |
\expandafter\pgfplotstableread@impl@ITERATE@NEXT@aftertextindicator\expandafter{\expandafter{\the\t@pgfplots@tokc}}% |
| 1557 |
}% |
| 1558 |
\def\pgfplotstableread@impl@ITERATE@NEXT@collect@text@finish@APPENDSPACE{% |
| 1559 |
% enclose the collected items into curly braces. This suppresses |
| 1560 |
% interpretation of extra chars: |
| 1561 |
\expandafter\pgfplotstableread@impl@ITERATE@NEXT@aftertextindicator\expandafter{\expandafter{\the\t@pgfplots@tokc}} % |
| 1562 |
}% |
| 1563 |
|
| 1564 |
|
| 1565 |
\long\def\pgfplotstableread@impl@ITERATE{% |
| 1566 |
\pgfutil@ifnextchar\pgfplotstable@EOI{% |
| 1567 |
\pgfplotstableread@impl@gobble |
| 1568 |
}{% |
| 1569 |
\pgfplotstableread@impl@ITERATE@NEXT |
| 1570 |
}% |
| 1571 |
}% |
| 1572 |
|
| 1573 |
\def\pgfplotstableread@impl@ITERATE@NEXT@checkindicator#1{% |
| 1574 |
\pgfutil@ifnextchar{#1}{% |
| 1575 |
% Ah! Our cell starts with a text indicator! Assume it is |
| 1576 |
% enclosed by text indicators. |
| 1577 |
\pgfplotstableread@impl@ITERATE@NEXT@checkindicator@gobble@one% |
| 1578 |
}{% |
| 1579 |
% ok, Cell does not start with a text indicator. collect |
| 1580 |
% as-is, assuming that a text indicator does not simply occur |
| 1581 |
% within a cell which is not enclosed by text indicators: |
| 1582 |
\pgfplotstableread@impl@ITERATE@NEXT@aftertextindicator |
| 1583 |
}% |
| 1584 |
}% |
| 1585 |
\def\pgfplotstableread@impl@ITERATE@NEXT@checkindicator@gobble@one#1{% |
| 1586 |
\t@pgfplots@tokc={}% |
| 1587 |
\pgfplotstableread@impl@ITERATE@NEXT@collect@text% |
| 1588 |
}% |
| 1589 |
|
| 1590 |
\long\def\pgfplotstableread@impl@ITERATE@NEXT#1 {% |
| 1591 |
\pgfplotstableread@impl@ITERATE@NEXT@{#1}% |
| 1592 |
\pgfplotstableread@impl@ITERATE |
| 1593 |
}% |
| 1594 |
\long\def\pgfplotstableread@impl@ITERATE@NEXT@COMMA#1,{% |
| 1595 |
\pgfplotstableread@impl@ITERATE@NEXT@{#1}% |
| 1596 |
\pgfplotstableread@impl@ITERATE |
| 1597 |
}% |
| 1598 |
\long\def\pgfplotstableread@impl@ITERATE@NEXT@SEMICOLON#1;{% |
| 1599 |
\pgfplotstableread@impl@ITERATE@NEXT@{#1}% |
| 1600 |
\pgfplotstableread@impl@ITERATE |
| 1601 |
}% |
| 1602 |
\long\def\pgfplotstableread@impl@ITERATE@NEXT@COLON#1:{% |
| 1603 |
\pgfplotstableread@impl@ITERATE@NEXT@{#1}% |
| 1604 |
\pgfplotstableread@impl@ITERATE |
| 1605 |
}% |
| 1606 |
\long\def\pgfplotstableread@impl@ITERATE@NEXT@BRACE#1{% |
| 1607 |
\pgfplotstableread@impl@ITERATE@NEXT@{#1}% |
| 1608 |
\pgfplotstableread@impl@ITERATE |
| 1609 |
}% |
| 1610 |
\long\def\pgfplotstableread@impl@ITERATE@NEXT@AMPERSAND#1&{% |
| 1611 |
\pgfplotstableread@impl@ITERATE@NEXT@{#1}% |
| 1612 |
\pgfplotstableread@impl@ITERATE |
| 1613 |
}% |
| 1614 |
\begingroup |
| 1615 |
\catcode`\^^I=12 |
| 1616 |
\gdef\pgfplotstableread@tab{^^I}% |
| 1617 |
\long\gdef\pgfplotstableread@impl@ITERATE@NEXT@TAB#1^^I{% the following white spaces are SPACES, not tabs: |
| 1618 |
\pgfplotstableread@impl@ITERATE@NEXT@{#1}% |
| 1619 |
\pgfplotstableread@impl@ITERATE |
| 1620 |
}% |
| 1621 |
\endgroup |
| 1622 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1623 |
|
| 1624 |
% these values are only usable for a read-listener, that means: |
| 1625 |
% when using |
| 1626 |
% |
| 1627 |
% \pgfplotstableread{<file>} to listener<\macro> |
| 1628 |
% |
| 1629 |
% -> <\macro> can than use the methods |
| 1630 |
% |
| 1631 |
% \pgfplotstablereadgetcolindex{<index>}{<\content>} |
| 1632 |
% performs \let\content=<content of column no <index> > |
| 1633 |
\def\pgfplotstablereadgetcolindex@#1#2{% |
| 1634 |
\pgfutil@ifundefined{pgfplotstblread@colcontent@no#1}{% |
| 1635 |
\pgfplotsthrow{no such element}{#2}{Sorry, the requested column number '#1' in table '\pgfplotstableread@filename' does not exist!? Please verify you used the correct index 0 <= i < N.}\pgfeov% |
| 1636 |
}{% |
| 1637 |
\expandafter\let\expandafter#2\csname pgfplotstblread@colcontent@no#1\endcsname |
| 1638 |
}% |
| 1639 |
}% |
| 1640 |
|
| 1641 |
\pgfkeysdef{/pgfplots/table/@undefined column text}{#1__column_not_found.}% |
| 1642 |
\def\pgfplotstable@undefinedtext#1{\pgfkeysvalueof{/pgfplots/table/@undefined column text/.@cmd}#1\pgfeov}% |
| 1643 |
|
| 1644 |
% As \pgfplotstablereadgetcolindex, but |
| 1645 |
% \pgfplotstablereadvalueofcolindex{<index>} |
| 1646 |
% directly expands to the value stored in the desired column. |
| 1647 |
% |
| 1648 |
% Example: |
| 1649 |
% \pgfplotstablereadvalueofcolindex{3} -> expands to '42' if '42' is |
| 1650 |
% written in column no 3. |
| 1651 |
% |
| 1652 |
% Column indexing starts at 0. |
| 1653 |
% |
| 1654 |
% @ATTENTION: since such a command may occur within an \edef or an |
| 1655 |
% \csname, it can't perform sanity checking. Proving an invalid index |
| 1656 |
% expands to \pgfkeysvalueof{/pgfplots/table/@undefined column text}. |
| 1657 |
\def\pgfplotstablereadvalueofcolindex@#1{% |
| 1658 |
\pgfutil@ifundefined{pgfplotstblread@colcontent@no#1}{% |
| 1659 |
\pgfplotstable@undefinedtext{colindex#1}% |
| 1660 |
}{% |
| 1661 |
\csname pgfplotstblread@colcontent@no#1\endcsname |
| 1662 |
}% |
| 1663 |
} |
| 1664 |
|
| 1665 |
% \pgfplotstablereadgetcolname{<name>}{<\content>} |
| 1666 |
% performs \let\content=<content of column named <name> > |
| 1667 |
\def\pgfplotstablereadgetcolname@#1#2{% |
| 1668 |
\pgfplotstablereadgetptrtocolname{#1}{\pgfplots@loc@TMPa}% |
| 1669 |
\pgfplotstablereadevalptr\pgfplots@loc@TMPa{#2}% |
| 1670 |
}% |
| 1671 |
|
| 1672 |
% This here is the implementation of \pgfplotstablereadvalueofcolname |
| 1673 |
% (and \thisrow{<colname>}) for use inside of the 'read to listener' |
| 1674 |
% framework. |
| 1675 |
% |
| 1676 |
% Like \pgfplotstablereadgetcolname, but this one expands directly to |
| 1677 |
% the value of the desired column. |
| 1678 |
% |
| 1679 |
% #1: a column name or a column alias. |
| 1680 |
% |
| 1681 |
% @ATTENTION: since such a command may occur within an \edef or an |
| 1682 |
% \csname, it can't perform sanity checking. Proving an invalid index |
| 1683 |
% expands to \pgfkeysvalueof{/pgfplots/table/@undefined column text}. |
| 1684 |
\def\pgfplotstablereadvalueofcolname@#1{% |
| 1685 |
\pgfplotstable@thisrow@impl{#1}{pgfplotstblread@colindex@for@name}{\pgfplotstable@thisrow@impl@read}% |
| 1686 |
}% |
| 1687 |
\def\pgfplotstable@thisrow@impl@read#1{\csname pgfplotstblread@colcontent@no#1\endcsname}% |
| 1688 |
|
| 1689 |
% This implements \thisrow in different contexts. |
| 1690 |
% |
| 1691 |
% Usage: |
| 1692 |
% \def\thisrow#1{\pgfplotstable@thisrow@impl{#1}{macroprefix@}{\pgfplotstable@thisrow@impl@}} |
| 1693 |
% |
| 1694 |
% Then, \thisrow{existingcol} |
| 1695 |
% will expand to |
| 1696 |
% -> \pgfplotstable@thisrow@impl@{\csname macroprefix@existingcol\endcsname} |
| 1697 |
% -> \csname macroprefix@existingcol\endcsname |
| 1698 |
% |
| 1699 |
% Furthermore, if '#1' is no existing col and there exists /pgfplots/table/alias/#1, |
| 1700 |
% \thisrow{aliased} |
| 1701 |
% will expand to |
| 1702 |
% -> \pgfplotstable@thisrow@impl@{\csname macroprefix@\pgfkeysvalueof{/pgfplots/table/alias/aliased}\endcsname} |
| 1703 |
% -> \csname macroprefix@\pgfkeysvalueof{/pgfplots/table/alias/aliased}\endcsname |
| 1704 |
% |
| 1705 |
% #1: the argument for \thisrow{#1} |
| 1706 |
% #2: a macro prefix such that \csname #2<colname>\endcsname contains |
| 1707 |
% the value of the current row for (physical) column <colname> |
| 1708 |
% #3: the name of a one-argument-macro which will get \csname #2<colname>\endcsname |
| 1709 |
% as argument. This is the last step of \thisrow. It allows indirect |
| 1710 |
% access by translating colnames to col indices in '\pgfplotstableread to listener' |
| 1711 |
\def\pgfplotstable@thisrow@impl#1#2#3{% |
| 1712 |
\pgfutil@ifundefined{#2#1}% |
| 1713 |
{% |
| 1714 |
% WARNING : this code has been REPLICATED in |
| 1715 |
% *** \pgfplotstablereadgetptrtocolname *** |
| 1716 |
% *** \pgfplotstablegetcolumnbyname *** |
| 1717 |
% *** \pgfplotstableresolvecolname *** |
| 1718 |
% *** \pgfplotstablereadvalueofcolname *** |
| 1719 |
\pgfkeysifdefined{/pgfplots/table/alias/#1}{% |
| 1720 |
\pgfutil@ifundefined{#2\pgfkeysvalueof{/pgfplots/table/alias/#1}}{% |
| 1721 |
\pgfplotstable@undefinedtext{\pgfkeysvalueof{/pgfplots/table/alias/#1}}% |
| 1722 |
}{% |
| 1723 |
#3{\csname #2\pgfkeysvalueof{/pgfplots/table/alias/#1}\endcsname}% |
| 1724 |
}% |
| 1725 |
}{% |
| 1726 |
\pgfplotstable@undefinedtext{#1}% |
| 1727 |
}% |
| 1728 |
}% |
| 1729 |
{% |
| 1730 |
#3{\csname #2#1\endcsname}% |
| 1731 |
}% |
| 1732 |
}% |
| 1733 |
\def\pgfplotstable@thisrow@impl@#1{#1}% |
| 1734 |
|
| 1735 |
% \pgfplotstablereadgetptrtocolname{<name>}{\ptr} |
| 1736 |
% Creates some sort of "pointer" to the column named <name>. This |
| 1737 |
% pointer can than be used every time a new line has been reported to |
| 1738 |
% the listener. It works like this: |
| 1739 |
% |
| 1740 |
% \let\ptr=\pgfutil@empty |
| 1741 |
% \def\macro{% |
| 1742 |
% \ifx\ptr\empty |
| 1743 |
% \pgfplotstablereadgetptrtocolname{<my col>}{\ptr}% |
| 1744 |
% \fi |
| 1745 |
% \pgfplotstablereadevalptr{\ptr}{\content}% |
| 1746 |
% -> do something with \content! |
| 1747 |
% } |
| 1748 |
% |
| 1749 |
% \pgfplotstableread{<file>} to listener<\macro> |
| 1750 |
% |
| 1751 |
% -> will evaluate \macro foreach row. |
| 1752 |
% |
| 1753 |
% The advantage of such a prepared pointer over \thisrow{#1} or |
| 1754 |
% \getthisrow{#1} is simply efficiency and sanity checking: the checks |
| 1755 |
% are done at the time of pointer creation, dereferencing the pointer |
| 1756 |
% is fast. |
| 1757 |
\def\pgfplotstablereadgetptrtocolname@#1#2{% |
| 1758 |
\def#2{0}% |
| 1759 |
\pgfplotstable@getcol{#1}\of{\pgfplotstableread@filename}\to{#2}\getcolmethod{getptr}% |
| 1760 |
}% |
| 1761 |
|
| 1762 |
% As \pgfplotstablereadgetptrtocolname, but this here accesses columns |
| 1763 |
% by index. |
| 1764 |
\def\pgfplotstablereadgetptrtocolindex@#1#2{\edef#2{#1}}% |
| 1765 |
|
| 1766 |
% \pgfplotstablereadevalptr{<\ptr>}{<\content} |
| 1767 |
% writes the current value of <\ptr> to <\content>. The pointer <\ptr> |
| 1768 |
% must be initialised with \pgfplotstablereadgetptrtocolname |
| 1769 |
\let\pgfplotstablereadevalptr@=\pgfplotstablereadgetcolindex@ |
| 1770 |
|
| 1771 |
% \pgfplotstablereadvalueofptr{<\ptr>} -> expands to the pointers value. |
| 1772 |
% |
| 1773 |
% The pointer \ptr must be initialised with |
| 1774 |
% \pgfplotstablereadgetptrtocolname. |
| 1775 |
\let\pgfplotstablereadvalueofptr@=\pgfplotstablereadvalueofcolindex@ |
| 1776 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1777 |
|
| 1778 |
\long\def\pgfplotstableread@impl@nextrow@NEXT@listener#1{% |
| 1779 |
\expandafter\def\csname pgfplotstblread@colcontent@no\thepgfplotstableread@curcol\endcsname{#1}% |
| 1780 |
\pgfplotstableread@countadvance\pgfplotstableread@curcol |
| 1781 |
} |
| 1782 |
|
| 1783 |
\long\def\pgfplotstableread@impl@nextrow@NEXT#1{% |
| 1784 |
%\pgfplots@message{Inserting '#1' at (\thepgfplotstableread@lineno, \thepgfplotstableread@curcol).}% |
| 1785 |
\ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax |
| 1786 |
\pgfplotslist@assembleentry{#1}\into\t@pgfplots@tokc |
| 1787 |
\def\pgfplotstableread@TMP{\expandafter\pgfplotsapplistXpushback\expandafter{\the\t@pgfplots@tokc}\to}% |
| 1788 |
\expandafter\pgfplotstableread@TMP\csname pgfp@numtable@glob@col@\thepgfplotstableread@curcol\endcsname |
| 1789 |
\pgfplotstableread@countadvance\pgfplotstableread@curcol |
| 1790 |
\else |
| 1791 |
\begingroup |
| 1792 |
\t@pgfplots@tokc={#1}% |
| 1793 |
\pgfplotsthrow{table columns unbalanced}{Table '\pgfplotstableread@filename' appears to have too many columns in line \thepgfplotstableread@lineno: Ignoring '\the\t@pgfplots@tokc'. PGFPlots found that the number of columns is larger than the previously determined number of columns. Please verify that every cell entry is separated correctly (use braces {<cell entry>} if necessary. Also verify that column names are plain ASCII.). This error is not critical}\pgfeov% |
| 1794 |
\endgroup |
| 1795 |
\fi |
| 1796 |
} |
| 1797 |
|
| 1798 |
|
| 1799 |
|
| 1800 |
\long\def\pgfplotstableread@impl@collectcolnames@NEXT#1{% |
| 1801 |
\edef\pgfplotstable@loc@TMPa{#1}% |
| 1802 |
\ifx\pgfplotstable@loc@TMPa\pgfutil@empty |
| 1803 |
\edef\pgfplotstable@loc@TMPa{\thepgfplotstableread@curcol}% |
| 1804 |
\pgfplotswarning{empty column name}{\pgfplotstableread@filename}{\pgfplotstable@loc@TMPa'}\pgfeov% |
| 1805 |
\fi |
| 1806 |
\expandafter\pgfplotstableread@impl@collectcolnames@NEXT@\expandafter{\pgfplotstable@loc@TMPa}% |
| 1807 |
} |
| 1808 |
\long\def\pgfplotstableread@impl@collectcolnames@NEXT@#1{% |
| 1809 |
%\pgfplots@message{Got column name no \thepgfplotstableread@curcol\ as '#1'}% |
| 1810 |
\pgfutil@ifundefined{pgfplotstableread@impl@COLNAME@#1}{% |
| 1811 |
\def\pgfplotstable@loc@TMPa{#1}% |
| 1812 |
}{% generate unique column names warning: |
| 1813 |
\pgfplots@warning{Table '\pgfplotstableread@filename' has non-unique column name '#1'. Only the first occurrence can be accessed via column names.}% |
| 1814 |
\edef\pgfplotstable@loc@TMPa{#1--index\thepgfplotstableread@curcol}% |
| 1815 |
}% |
| 1816 |
\expandafter\def\csname pgfplotstableread@impl@COLNAME@#1\endcsname{foo}% remember this name. |
| 1817 |
\expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@loc@TMPa}\to\pgfplotstable@colnames@glob |
| 1818 |
\ifpgfplots@tableread@to@listener |
| 1819 |
% create an associative container colindex -> colname |
| 1820 |
% for use in a listener. |
| 1821 |
\expandafter\edef\csname pgfplotstblread@colindex@for@name#1\endcsname{\thepgfplotstableread@curcol}% |
| 1822 |
\fi |
| 1823 |
\pgfplotstableread@countadvance\pgfplotstableread@curcol |
| 1824 |
} |
| 1825 |
|
| 1826 |
\long\def\pgfplotstableread@if@finite#1#2#3{% |
| 1827 |
\ifx#1\pgfutil@empty% |
| 1828 |
#3% |
| 1829 |
\else\ifx#1\pgfplotstableread@isnumber@nan% |
| 1830 |
#3% |
| 1831 |
\else\ifx#1\pgfplotstableread@isnumber@NaN% |
| 1832 |
#3% |
| 1833 |
\else\ifx#1\pgfplotstableread@isnumber@NAN% |
| 1834 |
#3% |
| 1835 |
\else\ifx#1\pgfplotstableread@isnumber@inf% |
| 1836 |
#3% |
| 1837 |
\else\ifx#1\pgfplotstableread@isnumber@Inf% |
| 1838 |
#3% |
| 1839 |
\else\ifx#1\pgfplotstableread@isnumber@INF% |
| 1840 |
#3% |
| 1841 |
\else% |
| 1842 |
#2% |
| 1843 |
\fi\fi\fi\fi\fi\fi\fi% |
| 1844 |
} |
| 1845 |
|
| 1846 |
|
| 1847 |
\long\def\pgfplotstableread@impl@countcols@and@identifynames@NEXT#1{% |
| 1848 |
\pgfplotstableread@countadvance\pgfplotstableread@curcol |
| 1849 |
\ifpgfplotstable@search@header |
| 1850 |
\ifpgfplotstableread@curline@contains@colnames |
| 1851 |
\else |
| 1852 |
\pgfplotstableread@if@finite{#1}{% |
| 1853 |
\pgfplotstableread@isnumber@ITERATE#1\pgfplotstable@EOI% |
| 1854 |
}{}% |
| 1855 |
%\ifpgfplotstableread@curline@contains@colnames\pgfplots@message{'#1' is a column name!}\else\pgfplots@message{'#1' is NO column name!}\fi |
| 1856 |
\fi |
| 1857 |
\fi |
| 1858 |
} |
| 1859 |
\def\pgfplotstableread@isnumber@nan{nan} |
| 1860 |
\def\pgfplotstableread@isnumber@NaN{NaN} |
| 1861 |
\def\pgfplotstableread@isnumber@NAN{NAN} |
| 1862 |
\def\pgfplotstableread@isnumber@inf{inf} |
| 1863 |
\def\pgfplotstableread@isnumber@INF{INF} |
| 1864 |
\def\pgfplotstableread@isnumber@Inf{Inf} |
| 1865 |
\def\pgfplotstableread@isnumber@plus{+} |
| 1866 |
\def\pgfplotstableread@isnumber@minus{-} |
| 1867 |
\def\pgfplotstableread@isnumber@zero{0} |
| 1868 |
\def\pgfplotstableread@isnumber@one{1} |
| 1869 |
\def\pgfplotstableread@isnumber@two{2} |
| 1870 |
\def\pgfplotstableread@isnumber@three{3} |
| 1871 |
\def\pgfplotstableread@isnumber@four{4} |
| 1872 |
\def\pgfplotstableread@isnumber@five{5} |
| 1873 |
\def\pgfplotstableread@isnumber@six{6} |
| 1874 |
\def\pgfplotstableread@isnumber@seven{7} |
| 1875 |
\def\pgfplotstableread@isnumber@eight{8} |
| 1876 |
\def\pgfplotstableread@isnumber@nine{9} |
| 1877 |
\def\pgfplotstableread@isnumber@e{e} |
| 1878 |
\def\pgfplotstableread@isnumber@E{E} |
| 1879 |
\def\pgfplotstableread@isnumber@period{.} |
| 1880 |
|
| 1881 |
\def\pgfplotstableread@isnumber@ITERATE#1{% |
| 1882 |
\def\pgfplotstableread@CURTOK{#1}% |
| 1883 |
\ifx\pgfplotstableread@CURTOK\pgfplotstable@EOI |
| 1884 |
\def\pgfplotstableread@NEXT{}% |
| 1885 |
\else |
| 1886 |
\def\pgfplotstableread@NEXT{\pgfplotstableread@isnumber@ITERATE}% |
| 1887 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@plus |
| 1888 |
\else |
| 1889 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@minus |
| 1890 |
\else |
| 1891 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@zero |
| 1892 |
\else |
| 1893 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@one |
| 1894 |
\else |
| 1895 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@two |
| 1896 |
\else |
| 1897 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@three |
| 1898 |
\else |
| 1899 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@four |
| 1900 |
\else |
| 1901 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@five |
| 1902 |
\else |
| 1903 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@six |
| 1904 |
\else |
| 1905 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@seven |
| 1906 |
\else |
| 1907 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@eight |
| 1908 |
\else |
| 1909 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@nine |
| 1910 |
\else |
| 1911 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@e |
| 1912 |
\else |
| 1913 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@E |
| 1914 |
\else |
| 1915 |
\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@period |
| 1916 |
\else |
| 1917 |
%\message{NO ITS NOT! Token: '\meaning\pgfplotstableread@CURTOK'}% |
| 1918 |
% it's no number, so it is a column name. |
| 1919 |
\pgfplotstableread@curline@contains@colnamestrue |
| 1920 |
\def\pgfplotstableread@NEXT{\pgfplotstableread@impl@gobble}% |
| 1921 |
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi |
| 1922 |
\fi |
| 1923 |
\pgfplotstableread@NEXT |
| 1924 |
} |
| 1925 |
|
| 1926 |
\def\pgfplotstable@error#1{\pgfplotsthrow{unsupported operation}{#1}\pgfeov}% |
| 1927 |
|
| 1928 |
|
| 1929 |
\def\pgfplotstableset{% |
| 1930 |
\pgfqkeys{/pgfplots/table}% |
| 1931 |
}% |
| 1932 |
|
| 1933 |
% Accepts a macro #1 which contains an argument denoting a column |
| 1934 |
% name. |
| 1935 |
% |
| 1936 |
% It checks whether #1 starts with '[index]', indicating that it is actually |
| 1937 |
% a column INDEX. If that is the case, |
| 1938 |
% \ifpgfplotstableread@foundcolnames is set to false and the index is |
| 1939 |
% returned into #1. |
| 1940 |
% |
| 1941 |
% Otherwise, \ifpgfplotstableread@foundcolnames is set to true. |
| 1942 |
\def\pgfplotstable@is@colname#1{% |
| 1943 |
\expandafter\pgfplotstabletypeset@is@colname@#1\pgfplotstable@EOI |
| 1944 |
\ifpgfplotstableread@foundcolnames |
| 1945 |
\else |
| 1946 |
\let#1=\pgfplotstable@loc@TMPa |
| 1947 |
\fi |
| 1948 |
}% |
| 1949 |
\def\pgfplotstabletypeset@is@colname@{% |
| 1950 |
\pgfutil@ifnextchar[{% |
| 1951 |
\pgfplotstabletypeset@is@colname@index |
| 1952 |
}{% |
| 1953 |
\pgfplotstableread@foundcolnamestrue |
| 1954 |
\pgfplotstabletypeset@is@colname@name |
| 1955 |
}% |
| 1956 |
} |
| 1957 |
\def\pgfplotstabletypeset@is@colname@index@@{index}% |
| 1958 |
\def\pgfplotstabletypeset@is@colname@index[#1]#2\pgfplotstable@EOI{% |
| 1959 |
\def\pgfplotstable@loc@TMPa{#1}% |
| 1960 |
\ifx\pgfplotstable@loc@TMPa\pgfplotstabletypeset@is@colname@index@@ |
| 1961 |
\pgfplotstableread@foundcolnamesfalse |
| 1962 |
\edef\pgfplotstable@loc@TMPa{#2}% |
| 1963 |
\else |
| 1964 |
\pgfplotstableread@foundcolnamestrue |
| 1965 |
\fi |
| 1966 |
}% |
| 1967 |
\def\pgfplotstabletypeset@is@colname@name#1\pgfplotstable@EOI{}% |
| 1968 |
|
| 1969 |
% calls \pgfplotstableset{every table={#1}} where '#1' is the table |
| 1970 |
% file name. |
| 1971 |
% |
| 1972 |
% Note that 'every table' is usually set *AFTER* any other option. In |
| 1973 |
% other words: settings in 'every table' have higher precedence than |
| 1974 |
% those provided, for example, at |
| 1975 |
% \pgfplotstabletypeset[<options>]{...}. |
| 1976 |
% |
| 1977 |
% Why? Well, the <options> need to be set *before* the file name |
| 1978 |
% argument is read. After all, it might contain an inline table for |
| 1979 |
% which \catcodes need to be adjusted -- and <options> might explain |
| 1980 |
% how. |
| 1981 |
% |
| 1982 |
% REMARK: An early attempt to change the precedence for 'every table' |
| 1983 |
% was to set <options> again after 'every table'. But that is |
| 1984 |
% incompatible with, for example '/.add={}{}' key handlers. |
| 1985 |
% |
| 1986 |
% This macro does nothing if 'every table' is empty. |
| 1987 |
% |
| 1988 |
% #1: the table name (argument to 'every table') |
| 1989 |
% #2: The <options> which have already been set. |
| 1990 |
\long\def\pgfplotstableset@every@table#1#2{% |
| 1991 |
\pgfkeysgetvalue{/pgfplots/table/every table/.@cmd}\pgfplotstable@loc@TMPa |
| 1992 |
\ifx\pgfplotstable@loc@TMPa\pgfplots@empty@style@key |
| 1993 |
\else |
| 1994 |
\pgfplotstableset{/pgfplots/table/every table={#1}}%,#2}% |
| 1995 |
\fi |
| 1996 |
}% |
| 1997 |
|
| 1998 |
\def\pgfplotstabletypeset{% |
| 1999 |
\pgfutil@ifnextchar[{% |
| 2000 |
\pgfplotstabletypeset@opt |
| 2001 |
}{% |
| 2002 |
\pgfplotstabletypeset@opt[]% |
| 2003 |
}% |
| 2004 |
} |
| 2005 |
\long\def\pgfplotstabletypeset@opt[#1]#2{% |
| 2006 |
\pgfplotstable@error@pkg{Please load \string\usepackage{pgfplotstable} before using \string\pgfplotstabletypeset}% |
| 2007 |
} |
| 2008 |
\let\pgfplotstabletypesetfile=\pgfplotstabletypeset |
| 2009 |
|
| 2010 |
\def\pgfplotstablecreatecol{% |
| 2011 |
\pgfutil@ifnextchar[{% |
| 2012 |
\pgfplotstablecreatecol@opt |
| 2013 |
}{% |
| 2014 |
\pgfplotstablecreatecol@opt[]% |
| 2015 |
}% |
| 2016 |
}% |
| 2017 |
\def\pgfplotstablecreatecol@opt[#1]#2#3{% |
| 2018 |
\pgfplotstable@error@pkg{Please load \string\usepackage{pgfplotstable} before using \string\pgfplotstablecreatecol}% |
| 2019 |
}% |
| 2020 |
|
| 2021 |
% Iterates through every column of table '#1' and invokes the code |
| 2022 |
% '#3' for each column. The current column name will be available as |
| 2023 |
% '#2' and the current column index as |\pgfplotstablecol| (starting |
| 2024 |
% with 0). |
| 2025 |
% |
| 2026 |
% Example: |
| 2027 |
% \pgfplotstableforeachcolumn{\table}\as\colname{% |
| 2028 |
% The column name is `\colname'; its index \pgfplotstablecol.\par |
| 2029 |
% }% |
| 2030 |
% |
| 2031 |
% REMARK: this routine does NOT introduce TeX groups. |
| 2032 |
\long\def\pgfplotstableforeachcolumn#1\as#2#3{% |
| 2033 |
\def\pgfplotstablecol{0}% |
| 2034 |
\pgfplotslistforeachungrouped#1\as#2{% |
| 2035 |
#3\relax% |
| 2036 |
\pgfplotsutil@advancestringcounter\pgfplotstablecol |
| 2037 |
}% |
| 2038 |
\let\pgfplotstablecol=\relax |
| 2039 |
}% |
| 2040 |
\let\pgfplotstableforeachcolumn@orig=\pgfplotstableforeachcolumn |
| 2041 |
|
| 2042 |
% A variant of \pgfplotstableforeachcolumn which is used inside of |
| 2043 |
% \pgfplotstableread to listener. |
| 2044 |
% |
| 2045 |
% It is used as \pgfplotstableforeachcolumn\as\cur{<do something with \cur>} |
| 2046 |
\long\def\pgfplotstableforeachcolumn@listener#1\as#2#3{% |
| 2047 |
\pgfplotstableforeachcolumn@orig\pgfplotstable@colnames@glob\as{#2}{#3}% |
| 2048 |
}% |
| 2049 |
|
| 2050 |
% Reports every element t_{ij} for a fixed column j (in read-only |
| 2051 |
% mode). |
| 2052 |
% |
| 2053 |
% For every cell, the code '#4' will be executed where '#3' will |
| 2054 |
% contain the cell's value. During code '#4', the macro |
| 2055 |
% \pgfplotstablerow will contain the current row index. |
| 2056 |
% |
| 2057 |
% #1: either a column name or the string '[index]' followed by a |
| 2058 |
% number denoting a column index Access by column name is much faster.. |
| 2059 |
% #2: the table (macro or file name) |
| 2060 |
% #3: the macro in which the cell values shall be written |
| 2061 |
% #4: the code to execute. |
| 2062 |
% |
| 2063 |
% Example: |
| 2064 |
% \pgfplotstableforeachcolumnelement{colname}\of\table\as\cellelem{% |
| 2065 |
% I have now cell element `\cellelem' at row index |
| 2066 |
% `\pgfplotstablerow'. |
| 2067 |
% \par |
| 2068 |
% } |
| 2069 |
% |
| 2070 |
% REMARK: this routine does NOT introduce TeX groups. |
| 2071 |
\long\def\pgfplotstableforeachcolumnelement#1\of#2\as#3#4{% |
| 2072 |
\def\pgfplotstablerow{0}% |
| 2073 |
\pgfplotstablegetcolumn{#1}\of{#2}\to\pgfplotstableforeachcolumnelement@list |
| 2074 |
\pgfplotslistforeachungrouped\pgfplotstableforeachcolumnelement@list\as#3{% |
| 2075 |
% allow nesting by copying the old value of \pgfplotstablerow: |
| 2076 |
\expandafter\pgfplotstableforeachcolumnelement@\expandafter{\pgfplotstablerow}{#4}% |
| 2077 |
}% |
| 2078 |
\let\pgfplotstablerow=\relax |
| 2079 |
}% |
| 2080 |
% helper method to allow nesting. It copies \pgfplotstablerow. |
| 2081 |
% #1: the expanded value of \pgfplotstablerow. |
| 2082 |
\long\def\pgfplotstableforeachcolumnelement@#1#2{% |
| 2083 |
#2\relax |
| 2084 |
\def\pgfplotstablerow{#1}% restore to old value. |
| 2085 |
% advance. |
| 2086 |
\pgfplotsutil@advancestringcounter\pgfplotstablerow |
| 2087 |
}% |
| 2088 |
|
| 2089 |
% A routine which is similar to \pgfplotstableforeachcolumnelement, |
| 2090 |
% but this here checks for changes in \pgfplotsretval and writes them |
| 2091 |
% back into the respected cell. |
| 2092 |
% |
| 2093 |
% The runtime is quadratic in the number of rows. |
| 2094 |
\long\def\pgfplotstablemodifyeachcolumnelement#1\of#2\as#3#4{% |
| 2095 |
\def\pgfplotstablerow{0}% |
| 2096 |
% |
| 2097 |
% Step 0: get the REAL column name for '#1'. |
| 2098 |
% This needs modifications if '#1' is [index]<integer>. |
| 2099 |
% -> store the colname to \pgfplotstable@loc@TMPc: |
| 2100 |
\def\pgfplotstable@loc@TMPc{#1}% |
| 2101 |
\pgfplotstable@is@colname{\pgfplotstable@loc@TMPc}%% |
| 2102 |
\ifpgfplotstableread@foundcolnames |
| 2103 |
\else |
| 2104 |
\expandafter\pgfplotstablegetcolumnnamebyindex\pgfplotstable@loc@TMPc\of{#2}\to\pgfplotstable@loc@TMPc |
| 2105 |
\fi |
| 2106 |
% Step 0.1: prepare a command which re-assembles column '#1' |
| 2107 |
% (using the real column name). |
| 2108 |
% The re-assemblation command will be invoked at the end of each |
| 2109 |
% iteration. This complicated macro preparation allows nested |
| 2110 |
% calls to \pgfplotstablemodifyeachcolumnelement. |
| 2111 |
\t@pgfplots@toka={\expandafter\pgfplotslistpushback\expandafter{#3}\to}% |
| 2112 |
\edef\pgfplotstable@loc@TMPd{% |
| 2113 |
\the\t@pgfplots@toka{\expandafter\noexpand\csname\string#2@\pgfplotstable@loc@TMPc\endcsname}}% |
| 2114 |
% Step 1: copy the column data to \pgfplotstable@loc@TMPb |
| 2115 |
\expandafter\pgfplotstablegetcolumnbyname\pgfplotstable@loc@TMPc\of#2\to\pgfplotstable@loc@TMPb% |
| 2116 |
% |
| 2117 |
% clear the original column: |
| 2118 |
\expandafter\pgfplotslistnewempty\csname\string#2@\pgfplotstable@loc@TMPc\endcsname |
| 2119 |
% |
| 2120 |
% Call loop. The prepared re-assemble macro will be provided as macro argument |
| 2121 |
% to allow nested calls: |
| 2122 |
\expandafter\pgfplotstablemodifyeachcolumnelement@\expandafter{\pgfplotstable@loc@TMPd} |
| 2123 |
{\pgfplotstable@loc@TMPb}{#3}{#4}% |
| 2124 |
\let\pgfplotstablerow=\relax |
| 2125 |
}% |
| 2126 |
% #1: post-iteration code |
| 2127 |
% #2: the row list |
| 2128 |
% #3: the loop macro to assign |
| 2129 |
% #4: the loop body |
| 2130 |
\long\def\pgfplotstablemodifyeachcolumnelement@#1#2#3#4{% |
| 2131 |
\pgfplotslistforeachungrouped{#2}\as#3{% |
| 2132 |
% allow nesting by copying the old value of \pgfplotstablerow: |
| 2133 |
\expandafter\pgfplotstableforeachcolumnelement@\expandafter{\pgfplotstablerow}{#4}% |
| 2134 |
#1% |
| 2135 |
}% |
| 2136 |
} |
| 2137 |
|
| 2138 |
% Selects a single table element at row #1 and column #2 from table |
| 2139 |
% #3. |
| 2140 |
% |
| 2141 |
% #1: a row index. |
| 2142 |
% #2: a column name or the string '[index]' followed by a number |
| 2143 |
% denoting a column index. Access by column name is much faster. |
| 2144 |
% #3: the table (macro or file name). |
| 2145 |
% |
| 2146 |
% The cell value will be written into the macro \pgfplotsretval. |
| 2147 |
% |
| 2148 |
% REMARK: |
| 2149 |
% this routine is supposed to be very slow: it needs time O(N) where N |
| 2150 |
% is the number of rows. This may change in future versions. |
| 2151 |
% |
| 2152 |
% Example: |
| 2153 |
% \pgfplotstablegetelem{0}{[index]2}\of\table |
| 2154 |
% The elem is `\pgfplotsretval'. |
| 2155 |
\def\pgfplotstablegetelem#1#2\of#3{% |
| 2156 |
\begingroup |
| 2157 |
\pgfplotstablegetcolumn{#2}\of{#3}\to\pgfplotstable@loc@TMPa |
| 2158 |
\def\pgfplotsexceptionmsg{Sorry, row `#1' does not exist in table \pgfplotstablenameof{#3}}% |
| 2159 |
\pgfplotslistselect#1\of\pgfplotstable@loc@TMPa\to\pgfplotsretval |
| 2160 |
\pgfmath@smuggleone\pgfplotsretval |
| 2161 |
\endgroup |
| 2162 |
}% |
| 2163 |
|
| 2164 |
\def\pgfplotstablegetcolumnlist#1\to#2{\let#2=#1} |
| 2165 |
|
| 2166 |
% Defines \pgfmathresult (and now also \pgfplotsretval) to be the number of rows in table #1. |
| 2167 |
% |
| 2168 |
% #1 may be either a loaded table structure (a macro name) or a table |
| 2169 |
% file name. In the latter case, the file will be loaded temporarily. |
| 2170 |
\long\def\pgfplotstablegetrowsof#1{% |
| 2171 |
\pgfplotstable@isloadedtable{#1}{% |
| 2172 |
% ah - it is an already loaded table! |
| 2173 |
\begingroup |
| 2174 |
\pgfplotslistfront#1\to\pgfplotstablegetrows@@ |
| 2175 |
\expandafter\pgfplotslistsize\csname\string#1@\pgfplotstablegetrows@@\endcsname\to\c@pgfplotstable@counta |
| 2176 |
\edef\pgfmathresult{\the\c@pgfplotstable@counta}% |
| 2177 |
\pgfmath@smuggleone\pgfmathresult |
| 2178 |
\endgroup |
| 2179 |
}{% |
| 2180 |
% ah - it is a file name. |
| 2181 |
\begingroup |
| 2182 |
\pgfplotstableread{#1}\pgfplotstablegetrows@ |
| 2183 |
\pgfplotstablegetrowsof{\pgfplotstablegetrows@}% |
| 2184 |
\pgfmath@smuggleone\pgfmathresult |
| 2185 |
\endgroup |
| 2186 |
}% |
| 2187 |
\let\pgfplotsretval=\pgfmathresult |
| 2188 |
}% |
| 2189 |
|
| 2190 |
% Defines \pgfplotsretval to contain the number of columns in table |
| 2191 |
% #1. |
| 2192 |
% |
| 2193 |
% #1 may be either a loaded table structure (a macro name) or a table |
| 2194 |
% file name. In the latter case, the file will be loaded temporarily. |
| 2195 |
\long\def\pgfplotstablegetcolsof#1{% |
| 2196 |
\pgfplotstable@isloadedtable{#1}{% |
| 2197 |
% ah - it is an already loaded table! |
| 2198 |
\begingroup |
| 2199 |
\pgfplotslistsize#1\to\c@pgfplotstable@counta |
| 2200 |
\edef\pgfplotsretval{\the\c@pgfplotstable@counta}% |
| 2201 |
\pgfmath@smuggleone\pgfplotsretval |
| 2202 |
\endgroup |
| 2203 |
}{% |
| 2204 |
% ah - it is a file name. |
| 2205 |
\begingroup |
| 2206 |
\pgfplotstableread{#1}\pgfplots@table |
| 2207 |
\pgfplotstablegetcolsof{\pgfplots@table}% |
| 2208 |
\pgfmath@smuggleone\pgfplotsretval |
| 2209 |
\endgroup |
| 2210 |
}% |
| 2211 |
\let\pgfmathresult=\pgfplotsretval |
| 2212 |
} |