summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex
blob: 82e27215bf4f1b5aa0aba3fecd9042be48d423a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
%--------------------------------------------
%
% Package numtable
%
% Provides support to read and work with abstact numeric tables of the
% form
%
% COLUMN1	COLUMN2 COLUMN3
% 1 		2		3
% 4			4		552
% 1e124		0.00001	1.2345e-12
% ...
%
% Copyright 2007/2008 by Christian Feuersänger.
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
% 
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
% 
% You should have received a copy of the GNU General Public License
% along with this program.  If not, see <http://www.gnu.org/licenses/>.
%
%--------------------------------------------

% This file relies on
% - pgfplotsliststructure.code.tex
% - pgfplotsarraystructure.code.tex
% - a (quite!) recent PGF.
%
% and needs some token registers. It does not use more of pgfplots.
%
\newif\ifpgfplotstable@search@header
\newcount\c@pgfplotstable@counta
\newwrite\pgfplotstable@outfile
\newif\ifpgfplotstabletypesetdebug
\newif\ifpgfplotstableuserow

% should always be false; use only in grouped internal macros
\newif\ifpgfplots@table@options@areset

\input pgfplotstable.coltype.code.tex

\pgfkeys{%
	/pgfplots/table/header/.is if=pgfplotstable@search@header,
	/pgfplots/table/header=true,
	/pgfplots/table/x index/.store in=\pgfplots@plot@tbl@xindex,
	/pgfplots/table/x index=0,
	/pgfplots/table/x/.store in=\pgfplots@plot@tbl@x,
	/pgfplots/table/x=,
	/pgfplots/table/y index/.store in=\pgfplots@plot@tbl@yindex,
	/pgfplots/table/y index=1,
	/pgfplots/table/y/.store in=\pgfplots@plot@tbl@y,
	/pgfplots/table/y=,
	/pgfplots/table/x error index/.initial=,
	/pgfplots/table/y error index/.initial=,
	/pgfplots/table/x error/.initial=,
	/pgfplots/table/y error/.initial=,
	/pgfplots/table/row predicate/.code={},
	/pgfplots/table/skip rows between index/.style 2 args={%
		/pgfplots/table/row predicate/.append code={%
			\ifnum##1<#1\relax
			\else
				\ifnum##1<#2\relax
					\pgfplotstableuserowfalse
				\fi
			\fi}
	},
	/pgfplots/table/col sep/.is choice,
	/pgfplots/table/col sep/space/.code		= {\def\pgfplotstableread@COLSEP@CASE{0}},
	/pgfplots/table/col sep/comma/.code		= {\def\pgfplotstableread@COLSEP@CASE{1}},
	/pgfplots/table/col sep/semicolon/.code	= {\def\pgfplotstableread@COLSEP@CASE{2}},
	/pgfplots/table/col sep/colon/.code		= {\def\pgfplotstableread@COLSEP@CASE{3}},
	/pgfplots/table/col sep/braces/.code	= {\def\pgfplotstableread@COLSEP@CASE{4}},
	/pgfplots/table/col sep=space,
	% columns={name1,name2}
	% or
	% columns={[index]2,name2,name3,[index]5}
	/pgfplots/table/columns/.initial=,
	/pgfplots/table/column name/.initial=\pgfkeysnovalue,
	%
	% this thing here allows to MODIFY 'column name'.
	%
	% Argument #1 is the current column name, that means after
	% evaluating 'column name'. If this key changes anything, it
	% should write its result back into 'column name'.
	%
	% That means you can use 'column name' to assign the name as such
	% and 'assign column name' to generate final TeX code (for example
	% to insert \multicolumn{1}{c}{#1} or so).
	% default is empty which means no change.
	%/pgfplots/table/assign column name/.code={
	%	\pgfkeyssetvalue{/pgfplots/table/column name}{#1}%
	%},
	%
	%
	%
	% A style which inserts \multicolumn{1}{#1}{<column name>} for
	% each column name.
	% The column name as such can be set with the 'column name' option.
	/pgfplots/table/multicolumn names/.style={%
		/pgfplots/table/assign column name/.code={%
			\pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{1}{#1}{##1}}%
		}%
	},
	/pgfplots/table/multicolumn names/.default=c,
	/pgfplots/table/dec sep align/.style={%
		/pgf/number format/assume math mode,
		/pgf/number format/set decimal separator/.add={&}{},
		/pgfplots/table/assign column name/.code={%
			\pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{2}{#1}{##1}}%
		},%
		/pgfplots/table/column type={>{$}r<{$}@{}>{$}l<{$}},
		/pgfplots/table/assign cell content/.code={%
			\pgfmathprintnumberto{##1}\pgfmathresult%
			\expandafter\pgfutil@in@\expandafter&\expandafter{\pgfmathresult}%
			\ifpgfutil@in@
			\else
				\expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult&}%
			\fi
			\pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
		},
	},
	/pgfplots/table/dec sep align/.default=c,
	%
	% A style which can be used together with the 'dcolumn' package by
	% David Carlisle.
	% #1: the dcolumn type, defaults to 'D{.}{.}{2}'
	% #2: the column name type, defaults to 'c'
	/pgfplots/table/dcolumn/.style 2 args={%
		/pgf/number format/assume math mode,
		column type={#1},
		multicolumn names=#2,
	},
	/pgfplots/table/dcolumn/.default={D{.}{.}{2}}{c},
	/pgfplots/table/column type/.initial={c},
	/pgfplots/table/every table/.style={},
	/pgfplots/table/every even row/.style={},
	/pgfplots/table/every odd row/.style={},
	/pgfplots/table/every last row/.style={},
	/pgfplots/table/every first row/.style={},
	/pgfplots/table/every head row/.style={},
	/pgfplots/table/every first column/.style={},
	/pgfplots/table/every last column/.style={},
	/pgfplots/table/every even column/.style={},
	/pgfplots/table/every odd column/.style={},
	/pgfplots/table/before row/.initial=,
	/pgfplots/table/after row/.initial=,
	/pgfplots/table/begin table/.initial={\begin{tabular}},
	/pgfplots/table/end table/.initial={\end{tabular}},
	/pgfplots/table/outfile/.initial=,
	/pgfplots/table/debug/.is if=pgfplotstabletypesetdebug,
	%
	% will be redefined by |assign cell content| for every cell:
	/pgfplots/table/@cell content/.initial=,
	%
	% #1: the cells content as it has been found in the input table
	% this command key should somehow fill |cell content|.
	/pgfplots/table/assign cell content/.code={%
		\pgfmathprintnumberto{#1}\pgfmathresult%
		\pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
	},
	%
	% this here is the default formatting. It uses
	% \pgfmathprintnumber.
	/pgfplots/table/assign cell content as number/.code={%
		\pgfmathprintnumberto{#1}\pgfmathresult%
		\pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
	},
	/pgfplots/table/string type/.style={%
		/pgfplots/table/assign cell content/.style={%
			/pgfplots/table/@cell content={##1}%
		}%
	},%
	/pgfplots/table/font/.initial=,
	/pgfplots/table/.unknown/.code={%
		\pgfqkeys{/pgf/number format}{\pgfkeyscurrentname=#1}%
	}%
}

% \pgfplotstableread[OPTIONS] {FILE} to \name
%
% This method reads a table from FILE to macro \name.
%
% FILE is something like
% G	Basis	dof	L2	A	Lmax	cgiter	maxlevel	eps
% 5	5	5	8.31160034e-02	0.00000000e+00	1.80007647e-01	2	2	-1
% 17	17	17	2.54685628e-02	0.00000000e+00	3.75580565e-02	5	3	-1
% ...
%
% A number format line is also understood:
% G	Basis	dof	L2	A	Lmax	cgiter	maxlevel	eps
% $flags int	int	int	sci:8	sci:8	sci:8	int	int	std:8
% 5	5	5	8.31160034e-02	0.00000000e+00	1.80007647e-01	2	2	-1
%
% or a three-column-gnuplot file with 2 comment headers like
% #Curve 0, 20 points
% #x y type
% 0.00000 0.00000 i
% 0.52632 0.50235 i
%
% The table data is stored columnwise in lists and can be accessed
% with the other methods of this package.
\def\pgfplotstableread{%
	\pgfutil@ifnextchar[{%
		\pgfplotstableread@impl
	}{%
		\pgfplotstableread@impl[]%
	}%
}

% BACKWARDS COMPATIBILITY
\let\pgfnumtableread=\pgfplotstableread

\def\pgfplotstablegetcolumnlist#1\to#2{%
	\let#2=#1
}

\def\pgfplotstablegetcolumnbyname#1\of#2\to#3{%
	\pgfutil@ifundefined{\string#2@#1}{%
		\pgfplots@error{Sorry, could not retrieve column '#1' from table...}%
	}{%
		\expandafter\let\expandafter#3\csname\string#2@#1\endcsname
	}%
}

\def\pgfplotstablegetcolumnnamebyindex#1\of#2\to#3{%
	\pgfplotslistselect#1\of#2\to#3\relax
}%
\def\pgfplotstablegetcolumnbyindex#1\of#2\to#3{%
	\pgfplotslistselect#1\of#2\to#3\relax
	\expandafter\pgfplotstablegetcolumnbyname#3\of#2\to{#3}%
}

\def\pgfplotstablecopy#1\to#2{%
	\let#2=#1%
	\pgfplotslistforeachungrouped#1\as\pgfplotstable@TMP{%
		\def\pgfplotstable@TMPB{%
			\expandafter\let\csname\string#2@\pgfplotstable@TMP\endcsname}%
		\expandafter\pgfplotstable@TMPB\csname\string#1@\pgfplotstable@TMP\endcsname
	}%
}

% Typesets a table.
%
% \pgfplotstabletypeset[<options>]<\tablestructure>
%
% If you do not select any columns, the complete table is drawn.
%
% There are several options and styles which are available in
% <options>, see the declaration above.
%
% ATTENTION: the default implementation employs
% \begin{tabular}...\end{tabular} and is therefor only usable with
% LaTeX!
%
% You will need to reconfigure the tables.
%
% Inside of \pgfplotstabletypeset, the macros \pgfplotstablecol and
% \pgfplotstablerow will expand to the current column index and row
% index.
\def\pgfplotstabletypeset{%
	\pgfutil@ifnextchar[{%	
		\pgfplotstabletypeset@opt
	}{%
		\pgfplotstabletypeset@opt[]%
	}%
}

% Like \pgfplotstabletypeset, but the first argument is a file name.
\def\pgfplotstabletypesetfile{%
	\pgfutil@ifnextchar[{%	
		\pgfplotstabletypesetfile@opt
	}{%
		\pgfplotstabletypesetfile@opt[]%
	}%
}
\def\pgfplotstabletypesetfile@opt[#1]#2{%
	\begingroup
	\ifpgfplots@table@options@areset
	\else
		\pgfplots@table@options@aresettrue
		\pgfplotstableset{/pgfplots/table/every table,#1}%
	\fi
	\pgfplotstableread{#2}\pgfplotstabletypesetfile@opt@@
	\pgfplotstabletypeset\pgfplotstabletypesetfile@opt@@
	\endgroup
}%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% IMPLEMENTATION
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\ifpgfplotstableread@curline@contains@colnames
\newif\ifpgfplotstableread@foundcolnames
\newif\ifpgfplotstableread@skipline
\def\pgfplotstableread@impl[#1]#2{%
	\pgfutil@ifnextchar t{%
		\pgfplotstableread@impl@@{#1}{#2}%
	}{%
		\pgfplotstableread@impl@{#1}{#2}%
	}%
}%

% I don't know why; but I started with 
% >> \pgfplotstableread[]{file} to \macro
% That ' to ' is really ugly. This here is for backwards
% compatibility:
\def\pgfplotstableread@impl@@#1#2to #3{%
	\pgfplotstableread@impl@{#1}{#2}{#3}%
}%

\def\pgfplotstableread@impl@#1#2#3{%
	\begingroup
	\ifpgfplots@table@options@areset
	\else
		\pgfplotstableset{/pgfplots/table/every table,#1}%
	\fi
%\pgfplots@message{ATTEMPTING TO READ #2}%
	\openin1=#2\relax
	\def\pgfplotstableread@filename{#2}%
	\let\pgfplotstableread@lineno=\c@pgf@counta
	\let\pgfplotstableread@numcols=\c@pgf@countb
	\let\pgfplotstableread@curcol=\c@pgf@countc
	\let\pgfplotstableread@usablelineno=\c@pgf@countd
	\pgfplotstableread@lineno=0
	\pgfplotstableread@usablelineno=0
	\pgfplotstableread@numcols=0
	\pgfplotslistnewempty\pgfplotstable@colnames
	\ifeof1
		\pgfplotstable@error{Could not read table file '#2'.}%
	\fi
	%
	\pgfplotstableread@loop@over@lines
	%
	\ifpgfplotstableread@foundcolnames
	\else
		\pgfplotstableread@create@column@names@with@numbers
	\fi
	% Well, now write the identified data to #3:
	%
	% make all temporaries global:
	\global\let\pgfplotstable@colnames=\pgfplotstable@colnames
	\pgfplotstableread@curcol=0\relax
	\loop
	\ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols
%\pgfplots@message{ASSIGNING COLUMN NO \the\pgfplotstableread@curcol / \the\pgfplotstableread@numcols}%
		% numtable@TMP := column list content
		\expandafter\global\expandafter\let\expandafter\pgfplotstable@TMP\csname numtable@col@\the\pgfplotstableread@curcol\endcsname
		% global := numtable@TMP
		\expandafter\global\expandafter\let\csname numtable@col@\the\pgfplotstableread@curcol\endcsname=\pgfplotstable@TMP
		\advance\pgfplotstableread@curcol by1\relax
	\repeat
	\closein1
	\endgroup
	% Now, we can access the global variables!
	% copy them to #3.
	\let#3=\pgfplotstable@colnames
	\c@pgfplotstable@counta=0\relax%
	\pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@TMP{%
		\def\pgfplotstable@TMPB{%
			\expandafter\let\csname\string#3@\pgfplotstable@TMP\endcsname}%
		\expandafter\pgfplotstable@TMPB\csname numtable@col@\the\c@pgfplotstable@counta\endcsname
%\message{Column '\pgfplotstable@TMP' has entries: \expandafter\meaning\csname numtable@col@\the\c@pgfplotstable@counta\endcsname}%
		\expandafter\global\expandafter\let\csname numtable@col@\the\c@pgfplotstable@counta\endcsname=\pgfutil@empty
		\advance\c@pgfplotstable@counta by1\relax
	}%
	\global\let\pgfplotstable@colnames=\pgfutil@empty
}

\def\pgfplotstableread@loop@over@lines{%
	\ifeof1
%\pgfplots@message{EOF}%
	\else
		\read1 to\pgfplotstable@LINE
		\ifeof1
		\else
		\expandafter\pgfplotstableread@checkspecial@line\pgfplotstable@LINE\pgfplotstable@EOI
		\ifpgfplotstableread@skipline
		\else
			%--------------------------------------------------
			% \ifnum\pgfplotstableread@lineno=0
			% 	\let\pgfplotstable@firstline=\pgfplotstable@LINE
			% \fi
			%-------------------------------------------------- 
%\pgfplots@message{READING LINE \the\pgfplotstableread@lineno: '\meaning\pgfplotstable@LINE'.}%
			\ifnum\pgfplotstableread@numcols=0\relax
				\pgfplotstableread@curcol=0\relax
				\pgfplotstableread@curline@contains@colnamesfalse
				\pgfplotstableread@impl@DO\pgfplotstableread@impl@countcols@and@identifynames@NEXT\pgfplotstable@LINE
				%\expandafter\pgfplotstableread@impl@countcols@and@identifynames@ITERATE\pgfplotstable@LINE\pgfplotstable@EOI
				\pgfplotstableread@numcols=\pgfplotstableread@curcol
				\pgfplotstableread@curcol=0\relax
				% Create empty column lists:
				\pgfplotstableread@create@column@lists
				%
				\ifnum\pgfplotstableread@usablelineno=0\relax
				\ifnum\pgfplotstableread@lineno=2\relax
				\ifnum\pgfplotstableread@numcols=3\relax
					% The file started with
					% #...
					% #...
					% X Y i
					% -> thats a gnuplot file!
					\pgfplotstableread@curline@contains@colnamesfalse
				\fi
				\fi
				\fi
				% Now, read the first line.
				% It contains either
				% - column names,
				% - numerical data,
				% - nothing (comments).
				\ifpgfplotstableread@curline@contains@colnames
					\pgfplotstableread@foundcolnamestrue
					\pgfplotstableread@curcol=0\relax
					\pgfplotstableread@impl@DO\pgfplotstableread@impl@collectcolnames@NEXT\pgfplotstable@LINE
					%\expandafter\pgfplotstableread@impl@collectcolnames@ITERATE\pgfplotstable@LINE\pgfplotstable@EOI
				\else
					\pgfplotstableread@foundcolnamesfalse
					\pgfplotstableread@curcol=0\relax
					% Leave column name lists empty...
					\pgfplotstableread@impl@DO\pgfplotstableread@impl@nextrow@NEXT\pgfplotstable@LINE
					%\expandafter\pgfplotstableread@impl@nextrow@ITERATE\pgfplotstable@LINE\pgfplotstable@EOI
				\fi
%\pgfplots@message{After reading first row: found '\the\pgfplotstableread@numcols' columns; column name list='\meaning\pgfplotstable@colnames'}%
			\else
				\pgfplotstableread@curcol=0\relax
				\pgfplotstableread@impl@DO\pgfplotstableread@impl@nextrow@NEXT\pgfplotstable@LINE
				%\expandafter\pgfplotstableread@impl@nextrow@ITERATE\pgfplotstable@LINE\pgfplotstable@EOI
			\fi
			\ifnum\pgfplotstableread@curcol=\pgfplotstableread@numcols
			\else
				\pgfplotstable@error{ERROR: the input table has an unexpected number of columns in row '\the\pgfplotstableread@lineno'. Expected: '\the\pgfplotstableread@numcols'; got '\the\pgfplotstableread@curcol. Maybe the input table is corrupted?}%
			\fi
			\advance\pgfplotstableread@usablelineno by1\relax
		\fi
		\fi
		\advance\pgfplotstableread@lineno by1\relax
		\pgfplotstableread@loop@over@lines
	\fi
}

\def\pgfplotstableread@checkspecial@line{%
	\pgfutil@ifnextchar##{%
		\pgfplotstableread@skiplinetrue
		\pgfplotstableread@impl@gobble
	}{%
		\pgfutil@ifnextchar${%
			\pgfplotstableread@process@flags@line
		}{%
			\pgfutil@ifnextchar\pgfplotstable@EOI{%
				\pgfplotstableread@skiplinetrue
				\pgfplotstableread@impl@gobble
			}{%
				\pgfutil@ifnextchar\par{%
					\pgfplotstableread@skiplinetrue
					\pgfplotstableread@impl@gobble
				}{%
					\pgfplotstableread@skiplinefalse
					\pgfplotstableread@impl@gobble
				}%
			}%
		}%
	}%
}

\long\def\pgfplotstableread@process@flags@line$flags {%
%\pgfplots@message{Ignoring flags line ...}%
	\pgfplotstableread@skiplinetrue
	\pgfplotstableread@impl@gobble
}

\def\pgfplotstableread@create@column@lists{%
	\loop
	\ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols
		\expandafter\pgfplotslistnewempty\csname numtable@col@\the\pgfplotstableread@curcol\endcsname
		\advance\pgfplotstableread@curcol by1\relax
	\repeat
}

\def\pgfplotstableread@create@column@names@with@numbers{%
	\pgfplotstableread@curcol=0\relax
	\loop
	\ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols
		\expandafter\pgfplotslistpushback\the\pgfplotstableread@curcol\to\pgfplotstable@colnames
		\advance\pgfplotstableread@curcol by1\relax
	\repeat
}

\long\def\pgfplotstableread@impl@gobble#1\pgfplotstable@EOI{}%

\def\pgfplotstable@EOI{\pgfplotstable@EOI}%

%%%%%%%%%%%%%%%

% A loop command which processes every single entry in a raw data row #2 
% and invokes the macro #1{<arg>}  for each found column entry.
%
% Columns are separated by the /pgfplots/table/col sep character.
%
% #1: a command which takes precisely one argument. It will be called
% for each found column entry
%
% #2: a macro containing a raw data line with <col sep> separated
% entries.
\def\pgfplotstableread@impl@DO#1#2{%
	\let\pgfplotstableread@impl@ITERATE@NEXT@=#1\relax
	\ifcase\pgfplotstableread@COLSEP@CASE\relax
		% SPACE:
		\expandafter\pgfplotstableread@impl@ITERATE#2\pgfplotstable@EOI
	\or
		% COMMA:
		\let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@COMMA
		\expandafter\pgfplotstableread@impl@ITERATE#2,\pgfplotstable@EOI
	\or
		% SEMICOLON:
		\let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@SEMICOLON
		\expandafter\pgfplotstableread@impl@ITERATE#2;\pgfplotstable@EOI
	\or
		% COLON:
		\let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@COLON
		\expandafter\pgfplotstableread@impl@ITERATE#2:\pgfplotstable@EOI
	\or
		% BRACE:
		\let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@BRACE
		\expandafter\pgfplotstableread@impl@ITERATE#2\pgfplotstable@EOI
	\fi
}%
\def\pgfplotstableread@impl@ITERATE{%
	\pgfutil@ifnextchar\pgfplotstable@EOI{%
		\pgfplotstableread@impl@gobble
	}{%
		\pgfplotstableread@impl@ITERATE@NEXT
	}%
}%
\def\pgfplotstableread@impl@ITERATE@NEXT#1 {%
	\pgfplotstableread@impl@ITERATE@NEXT@{#1}%
	\pgfplotstableread@impl@ITERATE
}%
\def\pgfplotstableread@impl@ITERATE@NEXT@COMMA#1,{%
	\pgfplotstableread@impl@ITERATE@NEXT@{#1}%
	\pgfplotstableread@impl@ITERATE
}%
\def\pgfplotstableread@impl@ITERATE@NEXT@SEMICOLON#1;{%
	\pgfplotstableread@impl@ITERATE@NEXT@{#1}%
	\pgfplotstableread@impl@ITERATE
}%
\def\pgfplotstableread@impl@ITERATE@NEXT@COLON#1:{%
	\pgfplotstableread@impl@ITERATE@NEXT@{#1}%
	\pgfplotstableread@impl@ITERATE
}%
\def\pgfplotstableread@impl@ITERATE@NEXT@BRACE#1{%
	\pgfplotstableread@impl@ITERATE@NEXT@{#1}%
	\pgfplotstableread@impl@ITERATE
}%
%%%%%%%%%%%%


\long\def\pgfplotstableread@impl@nextrow@NEXT#1{%
%\pgfplots@message{Inserting '#1' at (\the\pgfplotstableread@lineno, \the\pgfplotstableread@curcol).}%
	\def\pgfplotstableread@TMP{\pgfplotslistpushback#1\to}%
	\expandafter\pgfplotstableread@TMP\csname numtable@col@\the\pgfplotstableread@curcol\endcsname
	\advance\pgfplotstableread@curcol by1\relax
}



\long\def\pgfplotstableread@impl@collectcolnames@NEXT#1{%
%\pgfplots@message{Got column name no \the\pgfplotstableread@curcol\ as '#1'}%
	\pgfutil@ifundefined{pgfplotstableread@impl@COLNAME@#1}{%
		\def\pgfplotstable@TMP{#1}%
	}{% generate unique column names
		\pgfplots@warning{Warning: table '\pgfplotstableread@filename' has non-unique column name '#1'. Only the first occurence can be accessed via column names.}%
		\edef\pgfplotstable@TMP{#1--index\the\pgfplotstableread@curcol}%
	}%
	\expandafter\def\csname pgfplotstableread@impl@COLNAME@#1\endcsname{foo}% remember this name.
	\expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@TMP}\to\pgfplotstable@colnames
	\advance\pgfplotstableread@curcol by1\relax
}




\long\def\pgfplotstableread@impl@countcols@and@identifynames@NEXT#1{%
	\advance\pgfplotstableread@curcol by1\relax
	\ifpgfplotstable@search@header
		\ifpgfplotstableread@curline@contains@colnames
		\else
			\pgfplotstableread@isnumber@ITERATE#1\pgfplotstable@EOI
%\ifpgfplotstableread@curline@contains@colnames\pgfplots@message{'#1' is a column name!}\else\pgfplots@message{'#1' is NO column name!}\fi
		\fi
	\fi
}
\def\pgfplotstableread@isnumber@plus{+}
\def\pgfplotstableread@isnumber@minus{-}
\def\pgfplotstableread@isnumber@zero{0}
\def\pgfplotstableread@isnumber@one{1}
\def\pgfplotstableread@isnumber@two{2}
\def\pgfplotstableread@isnumber@three{3}
\def\pgfplotstableread@isnumber@four{4}
\def\pgfplotstableread@isnumber@five{5}
\def\pgfplotstableread@isnumber@six{6}
\def\pgfplotstableread@isnumber@seven{7}
\def\pgfplotstableread@isnumber@eight{8}
\def\pgfplotstableread@isnumber@nine{9}
\def\pgfplotstableread@isnumber@e{e}
\def\pgfplotstableread@isnumber@E{E}
\def\pgfplotstableread@isnumber@period{.}

\def\pgfplotstableread@isnumber@ITERATE#1{%
	\def\pgfplotstableread@CURTOK{#1}%
	\ifx\pgfplotstableread@CURTOK\pgfplotstable@EOI
		\def\pgfplotstableread@NEXT{}%
	\else
		\def\pgfplotstableread@NEXT{\pgfplotstableread@isnumber@ITERATE}%
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@plus
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@minus
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@zero
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@one
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@two
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@three
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@four
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@five
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@six
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@seven
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@eight
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@nine
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@e
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@E
		\else
		\ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@period
		\else
%\message{NO ITS NOT!  Token: '\meaning\pgfplotstableread@CURTOK'}%
			% it's no number, so it is a column name.
			\pgfplotstableread@curline@contains@colnamestrue
			\def\pgfplotstableread@NEXT{\pgfplotstableread@impl@gobble}%
		\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
	\fi
	\pgfplotstableread@NEXT
}

\def\pgfplotstable@error#1{\PackageError{numtable}{#1}{Please refer to the manual for further information.}}%


\def\pgfplotstableset{%
	\pgfqkeys{/pgfplots/table}%
}%

% Accepts a macro #1 which contains an argument denoting a column
% name.
%
% It checks whether #1 starts with '#', indicating that it is actually
% a column INDEX. If that is the case,
% \ifpgfplotstableread@foundcolnames is set to false and the index is
% returned into #1.
%
% Otherwise, \ifpgfplotstableread@foundcolnames is set to true.
\def\pgfplotstabletypeset@is@colname#1{%
	\expandafter\pgfplotstabletypeset@is@colname@#1\pgfplotstable@EOI
	\ifpgfplotstableread@foundcolnames
	\else
		\let#1=\pgfplotstable@TMP
	\fi
}%
\def\pgfplotstabletypeset@is@colname@{%
	\pgfutil@ifnextchar[{%
		\pgfplotstabletypeset@is@colname@index
	}{%
		\pgfplotstableread@foundcolnamestrue
		\pgfplotstabletypeset@is@colname@name
	}%
}
\def\pgfplotstabletypeset@is@colname@index@@{index}%
\def\pgfplotstabletypeset@is@colname@index[#1]#2\pgfplotstable@EOI{%
	\def\pgfplotstable@TMP{#1}%
	\ifx\pgfplotstable@TMP\pgfplotstabletypeset@is@colname@index@@
		\pgfplotstableread@foundcolnamesfalse
		\def\pgfplotstable@TMP{#2}%
	\else
		\pgfplotstableread@foundcolnamestrue
	\fi
}%
\def\pgfplotstabletypeset@is@colname@name#1\pgfplotstable@EOI{}%
\def\pgfplotstabletypeset@getfinalentry#1#2{%
	\pgfkeysvalueof{/pgfplots/table/assign cell content/.@cmd}#1\pgfeov
	\pgfkeysgetvalue{/pgfplots/table/@cell content}{#2}%
}%

% processes the option 'assign column name'
\def\pgfplotstabletypeset@assign@final@colname#1#2{%
	\pgfkeysifdefined{/pgfplots/table/assign column name/.@cmd}{%
		\pgfkeysvalueof{/pgfplots/table/assign column name/.@cmd}#1\pgfeov
		\pgfkeysgetvalue{/pgfplots/table/column name}{#2}%
	}{}%
}
\def\pgfplotstabletypeset@nocolname{\pgfkeysnovalue}

% checks if #1 contains invalid chars for pgfkeys and sets
% \ifpgfutil@in@ to true if that is the case.
\def\pgfplotstable@checkspecialchars@pgfkeys#1\pgfplotstable@EOI{%
	\pgfutil@in@/{#1}%
	\ifpgfutil@in@
	\else
		\pgfutil@in@={#1}%
		\ifpgfutil@in@
		\else
			\pgfutil@in@,{#1}%
		\fi
	\fi

}%

% TODO
% - replace grouped list foreach by popfront-loop and use arrays
%   directly -> group only the pgfkeys eval
\def\pgfplotstabletypeset@opt[#1]#2{%
	\begingroup
	\def\pgfplotstablecol{\the\c@pgfplotstable@colindex}%
	\def\pgfplotstablerow{\the\c@pgfplotstable@rowindex}%
%	\def\pgfplotstablecols{\the\c@pgfplotstable@numcols}%
%	\def\pgfplotstablerows{\the\c@pgfplotstable@numrows}%
	\ifpgfplots@table@options@areset
	\else
		\pgfplotstableset{/pgfplots/table/every table,#1}%
	\fi
	\pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}%
	\ifx\pgfplotstable@colnames\pgfutil@empty
		\pgfplotstablegetcolumnlist#2\to\pgfplotstable@colnames
	\else
		\expandafter\pgfplotslistnew\expandafter\pgfplotstable@colnames\expandafter{\pgfplotstable@colnames}%
	\fi
	\global\pgfplotslistnewempty\pgfplotstabletypeset@final@colnames
	\global\pgfplotslistnewempty\pgfplotstabletypeset@final@coltypes
	\global\pgfplotslistnewempty\pgfplotstabletypeset@final@cols
	\let\c@pgfplotstable@numcols=\c@pgf@counta
	\let\c@pgfplotstable@numrows=\c@pgf@countd
	\let\c@pgfplotstable@rowindex=\c@pgf@countc
	\let\c@pgfplotstable@colindex=\c@pgf@countb
	\pgfplotslistsize\pgfplotstable@colnames\to\c@pgfplotstable@numcols
	\c@pgfplotstable@colindex=0\relax
	\pgfplotslistforeach\pgfplotstable@colnames\as\pgfplotstable@colname{%
		\c@pgfplotstable@rowindex=0\relax
		\pgfplotstabletypeset@is@colname\pgfplotstable@colname
		\ifpgfplotstableread@foundcolnames
		\else
			\pgfplotstablegetcolumnnamebyindex\pgfplotstable@colname\of#2\to\pgfplotstable@colname
		\fi
		\pgfplotstablegetcolumnbyname\pgfplotstable@colname\of#2\to\pgfplotstable@col
		%
		% Set keys for columns!
		\ifodd\c@pgfplotstable@colindex
			\pgfplotslist@TOK@a={every odd column}%
		\else
			\pgfplotslist@TOK@a={every even column}%
		\fi
		\ifnum\c@pgfplotstable@colindex=0\relax
			\pgfplotslist@TOK@a=\expandafter{\the\pgfplotslist@TOK@a,every first column}%
		\fi
		\global\advance\c@pgfplotstable@colindex by1\relax
		\ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols
			\pgfplotslist@TOK@a=\expandafter{\the\pgfplotslist@TOK@a,every last column}%
		\fi
		\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@colname}%
		\expandafter\pgfplotstable@checkspecialchars@pgfkeys\the\pgfplotslist@TOK@b\pgfplotstable@EOI
		\ifpgfutil@in@
			\edef\pgfplotstable@TMP{\the\pgfplotslist@TOK@a,columns/{\the\pgfplotslist@TOK@b}/.try}%
		\else
			\edef\pgfplotstable@TMP{\the\pgfplotslist@TOK@a,columns/\the\pgfplotslist@TOK@b/.try}%
		\fi
		\expandafter\pgfplotstableset\expandafter{\pgfplotstable@TMP}%
		%
		\pgfkeysgetvalue{/pgfplots/table/column name}{\pgfplotstable@colname@out}%
		\ifx\pgfplotstable@colname@out\pgfplotstabletypeset@nocolname
			\let\pgfplotstable@colname@out=\pgfplotstable@colname
		\fi
		\expandafter\pgfplotstabletypeset@assign@final@colname\expandafter{\pgfplotstable@colname@out}\pgfplotstable@colname@out
		{\globaldefs=1
		\expandafter\pgfplotslistpushback\pgfplotstable@colname@out\to\pgfplotstabletypeset@final@colnames
		}%
		\pgfkeysgetvalue{/pgfplots/table/column type}{\pgfplotstable@coltype}%
		{\globaldefs=1
		\expandafter\pgfplotslistpushback\pgfplotstable@coltype\to\pgfplotstabletypeset@final@coltypes
		}%
		%
		\pgfplotslistnewempty\pgfplotstable@col@processed
		\pgfplotslistforeachungrouped\pgfplotstable@col\as\pgfplotstable@entry{%
			\pgfplotstableuserowtrue
			\edef\pgfplotstable@TMP{\noexpand\pgfkeysvalueof{/pgfplots/table/row predicate/.@cmd}\the\c@pgfplotstable@rowindex}%
			\pgfplotstable@TMP\pgfeov
			\ifpgfplotstableuserow
				\expandafter\pgfplotstabletypeset@getfinalentry\expandafter{\pgfplotstable@entry}{\pgfplotstable@entry}%
				\expandafter\pgfplotslistpushback\pgfplotstable@entry\to\pgfplotstable@col@processed
			\fi
			\advance\c@pgfplotstable@rowindex by1\relax
		}%
		{\globaldefs=1
		\expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@col@processed}\to\pgfplotstabletypeset@final@cols
		}%
	}%
	%
	% Ok, I have now everything which will come into the final table.
	%
	% But I have it column-oriented; I need to transpose the storage.
	%
	% The following code assembles a
	% \begin{tabular}{}
	% ...
	% \end{tabular}
	% statement piece after piece.
	%
%\message{I have now \meaning\pgfplotstabletypeset@final@colnames, and \meaning\pgfplotstabletypeset@final@cols.}%
	% Step 1: column names.
	\c@pgfplotstable@colindex=0\relax
	% STEP 1.1: collect column types:
	\def\pgfplotstable@resulttypes{}%
	\pgfplotslistforeachungrouped\pgfplotstabletypeset@final@coltypes\as\pgfplotstable@coltype{%
		\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@resulttypes}%
		\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@coltype}%
		\edef\pgfplotstable@resulttypes{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}%
	}%
	\pgfkeysgetvalue{/pgfplots/table/begin table}{\pgfplotstable@entry}%
	\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@entry}%
	\ifx\pgfplotstable@resulttypes\pgfutil@empty
		\edef\pgfplotstable@result{\the\pgfplotslist@TOK@a}%
	\else
		\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@resulttypes}%
		\edef\pgfplotstable@result{\the\pgfplotslist@TOK@a{\the\pgfplotslist@TOK@b}}%
	\fi
	%
	\pgfkeysgetvalue{/pgfplots/table/font}{\pgfplotstable@font}%
	\ifx\pgfplotstable@font\pgfutil@empty
	\else
		\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@font}%
		\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@result}%
		\edef\pgfplotstable@result{\noexpand\begingroup\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}%
	\fi
	%

	% Step 1.2: Collect FIRST ROW (column names)
	\begingroup
	\pgfplotstableset{every head row}%
	\pgfkeysgetvalue{/pgfplots/table/before row}{\pgfplotstable@before}%
	\pgfkeysgetvalue{/pgfplots/table/after row}{\pgfplotstable@after}%
	\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@before}%
	\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@after}%
	\xdef\pgfplotstable@TMP{%
		\noexpand\def\noexpand\pgfplotstable@before{\the\pgfplotslist@TOK@a}%
		\noexpand\def\noexpand\pgfplotstable@after{\the\pgfplotslist@TOK@b}%
	}%
	\endgroup
	\pgfplotstable@TMP
	% insert 'before row' here:
	\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@before}%
	\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@result}%
	\edef\pgfplotstable@result{\the\pgfplotslist@TOK@b\the\pgfplotslist@TOK@a}%
	%
	\pgfplotslistforeachungrouped\pgfplotstabletypeset@final@colnames\as\pgfplotstable@colname@out{%
		\advance\c@pgfplotstable@colindex by1\relax
		\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}%
		\ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax
			\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@colname@out \\}%
		\else
			\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@colname@out &}%
		\fi
		\edef\pgfplotstable@result{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}%
	}%
	% insert 'after row' here:
	\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}%
	\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@after}%
	\edef\pgfplotstable@result{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}%
	%
%\message{I have now \meaning\pgfplotstable@result.}%
	% Step 2: column contents.
	% I will first convert \pgfplotstabletypeset@final@cols into an array.
	\c@pgfplotstable@colindex=0\relax
	\pgfplotsarraynewempty\pgfplotstabletypeset@final@cols@array
	\pgfplotslistforeachungrouped\pgfplotstabletypeset@final@cols\as\pgfplotstable@col@processed{%
		\expandafter\pgfplotsarraypushback\expandafter{\pgfplotstable@col@processed}\to\pgfplotstabletypeset@final@cols@array
	}%
	% init numrows:
	\pgfplotsarrayselect\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array\to\pgfplotstable@col@processed
	\pgfplotslistsize\pgfplotstable@col@processed\to\c@pgfplotstable@numrows
	%
	% Now, we loop over every column as long as there are still rows
	% left. We assemble rows while we go.
	%
	\c@pgfplotstable@rowindex=0\relax
	\ifnum\c@pgfplotstable@colindex<\c@pgfplotstable@numcols
		\pgfplots@loop@CONTINUEtrue
	\else
		\pgfplots@loop@CONTINUEfalse
	\fi
	\loop
	\ifpgfplots@loop@CONTINUE
		\pgfplotsarrayselect\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array\to\pgfplotstable@col@processed
		\pgfplotslistcheckempty\pgfplotstable@col@processed
		\ifpgfplotslistempty
			\pgfplots@loop@CONTINUEfalse
		\else
			\ifnum\c@pgfplotstable@colindex=0\relax
				% Install styles for the next row.
				\begingroup
				\ifodd\c@pgfplotstable@rowindex
					\pgfplotslist@TOK@a={every odd row}%
				\else
					\pgfplotslist@TOK@a={every even row}%
				\fi
				\ifnum\c@pgfplotstable@rowindex=0\relax
					\pgfplotslist@TOK@a=\expandafter{\the\pgfplotslist@TOK@a,every first row}%
				\fi
				% misuse as temporary variable:
				\c@pgfplotstable@colindex=\c@pgfplotstable@rowindex
				\advance\c@pgfplotstable@colindex by1\relax
				\ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numrows
					\edef\pgfplotstable@TMP{\the\pgfplotslist@TOK@a,every row no \the\c@pgfplotstable@rowindex/.try,every last row}%
				\else
					\edef\pgfplotstable@TMP{\the\pgfplotslist@TOK@a,every row no \the\c@pgfplotstable@rowindex/.try}%
				\fi
				\expandafter\pgfplotstableset\expandafter{\pgfplotstable@TMP}%
				\pgfkeysgetvalue{/pgfplots/table/before row}{\pgfplotstable@before}%
				\pgfkeysgetvalue{/pgfplots/table/after row}{\pgfplotstable@after}%
				\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@before}%
				\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@after}%
				\xdef\pgfplotstable@TMP{%
					\noexpand\def\noexpand\pgfplotstable@before{\the\pgfplotslist@TOK@a}%
					\noexpand\def\noexpand\pgfplotstable@after{\the\pgfplotslist@TOK@b}%
				}%
				\endgroup
				\pgfplotstable@TMP
				% insert 'before row' here:
				\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@before}%
				\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@result}%
				\edef\pgfplotstable@result{\the\pgfplotslist@TOK@b\the\pgfplotslist@TOK@a}%
			\fi
			%
			%
			\pgfplotslistpopfront\pgfplotstable@col@processed\to\pgfplotstable@entry
			\pgfplotsarrayletentry\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array=\pgfplotstable@col@processed
			\advance\c@pgfplotstable@colindex by1\relax
			\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}%
			\ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax
				\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@entry \\}%
			\else
				\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@entry &}%
			\fi
			\edef\pgfplotstable@result{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}%
			\ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax
				\c@pgfplotstable@colindex=0\relax
				% insert 'after row' here:
				\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}%
				\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@after}%
				\edef\pgfplotstable@result{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}%
				\advance\c@pgfplotstable@rowindex by1\relax
			\fi
%\message{I have now \meaning\pgfplotstable@result.}%
		\fi
	\repeat
	\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}%
	\pgfkeysgetvalue{/pgfplots/table/end table}{\pgfplotstable@entry}%
	\pgfplotslist@TOK@b=\expandafter{\pgfplotstable@entry}%
	\edef\pgfplotstable@result{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}%
	\ifx\pgfplotstable@font\pgfutil@empty
	\else
		\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result\endgroup}%
		\edef\pgfplotstable@result{\the\pgfplotslist@TOK@a}%
	\fi
	\ifpgfplotstabletypesetdebug
		\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}%
		\immediate\write16{------- PGFPLOTSTABLE DEBUG MODE: --------}%
		\immediate\write16{{\the\pgfplotslist@TOK@a}}%
	\fi
	\pgfkeysgetvalue{/pgfplots/table/outfile}{\pgfplotstable@entry}%
	\ifx\pgfplotstable@entry\pgfutil@empty
	\else
		\begingroup
		\immediate\openout\pgfplotstable@outfile=\pgfplotstable@entry\relax
		\pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}%
		\immediate\write\pgfplotstable@outfile{\the\pgfplotslist@TOK@a}%
		\immediate\closeout\pgfplotstable@outfile
		\endgroup
	\fi
	\pgfplotstable@result
	\endgroup
}%


\endinput