[pstricks] Generate Table via \readdata
Buddy Ledger
buddyledger at gmail.com
Tue Apr 21 02:35:09 CEST 2009
Thanks Herbert, works great. How would I include a \hline command to
produce the row separation lines? the code below gives a misplaced
\noalign error.
\begin{filecontents*}{errorbar.dat}
1.00E+001 2.00E+001 3.00E+001 4.00E+001
2.00E+001 3.00E+001 4.00E+001 5.00E+001
3.00E+001 4.00E+001 5.00E+001 6.00E+001
4.00E+001 5.00E+001 6.00E+001 7.00E+001
\end{filecontents*}
\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage{pstricks-add}
\makeatletter
\def\checkEntries#1 #2#3\@nil{%
\def\@tempA{#3}
\ifx\@tempA\@empty\else
\global\advance\pst at cnta\@ne%
\expandafter\checkEntries#2#3\@nil
\fi}
\def\readLine#1#2{%
\openin1=#1
\read1 to \pst at tempa
\global\pst at cnta=0
\expandafter\checkEntries\pst at tempa\space\@nil
\advance\pst at cnta\@ne
\gdef#2{\the\pst at cnta}\ignorespaces}
\def\fillTab at i#1{\fillTab at ii#1}
\def\fillTab at ii D #1 {%
\global\advance\pst at cntm by \@ne
#1 \ifnum\pst at cntm=\pst at cntn \global\pst at cntm=0 \tabularnewline \hline \else
& \fi
\@ifnextchar D\fillTab at ii{}}
\def\fillTab#1{%
\global\pst at cntm=0
\global\pst at cntn=\dataNo
\expandafter\fillTab at i#1}
\makeatother
\begin{document}
\readLine{errorbar.dat}{\dataNo}
\readdata{\data}{errorbar.dat}
\begin{tabular}{|*{\dataNo}{r|}}\hline
\fillTab{\data}\\\hline
\end{tabular}
\end{document}
Thanks
Buddy Ledger
More information about the PSTricks
mailing list