[pstricks] Generate Table via \readdata

Herbert Voss Herbert.Voss at FU-Berlin.DE
Tue Apr 21 08:58:10 CEST 2009


Buddy Ledger schrieb:
> 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.

I am a bit lost here ... :-( don't know why the last column
appears. Maybe others can have a look, what'S going wrong.

HEbrert


\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage{filecontents}% allows overwriting
\begin{filecontents*}{doterrorbar.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*}

\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 {%
  #1
  \global\advance\pst at cntm by \@ne
  \ifnum\pst at cntm>\dataNo
    \global\pst at cntm=\@ne
    \\\hline \else & \fi
  \@ifnextchar D\fillTab at ii{}}
\def\fillTab#1{%
  \global\pst at cntm=\@ne
  \expandafter\fillTab at i#1}
\makeatother
\parindent=0pt
\begin{document}
\readLine{doterrorbar.dat}{\dataNo}
\readdata{\data}{doterrorbar.dat}

the data:\\
\ttfamily|\data|


\bigskip
\begin{tabular}{|*{\dataNo}{r|}}\hline
\fillTab{\data}
\end{tabular}

\end{document}



More information about the PSTricks mailing list