[pstricks] ignore first n rows with \readdata
Herbert Voss
LaTeX at zedat.fu-berlin.de
Sat Apr 2 19:43:15 CEST 2005
----- Original Message -----
>From: "Patrick Drechsler" <patrick at pdrechsler.de>
>To: <pstricks at tug.org>
>Sent: Thursday, March 31, 2005 11:10 PM
>Subject: Re: [pstricks] ignore first n rows with \readdata
>
>
>>The only drawback is that one has to know the column
>>names. Ignoring the first line would be easier (for the
>>user). But I have no idea if this is possible in postscript.
>>
>>For my current work your solution is fine, since I do not have to
>>delete the first line in my data sets.
>>
try this demo
Herbert
\begin{filecontents*}{demo9.dat}
some nonsense in this line äöüÖÜß
time forcex forcey
0 0.2
1 1
2 4
\end{filecontents*}
%
\documentclass[a4paper]{article}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{pst-xkey}
\makeatletter
\define at key[psset]{}{ignoreLines}{\def\psk at ignoreLines{#1}}
\psset{ignoreLines=0}
%
\def\readdata{\@ifnextchar[{\readdata at i}{\readdata at i[]}}
\def\readdata at i[#1]#2#3{%
\psset{#1}
\openin1=#3
\begingroup
\def\pst at tempg{}%
\ifeof1
\@pstrickserr{Data file `#3' not found.}\@ehpa
\else
\pst at datadelimiters
\catcode`\[=1
\catcode`\]=2
\pst at cnta=0
\loop \ifnum\the\pst at cnta<\psk at ignoreLines
\advance\pst at cnta by 1\relax
\read1 to \pst at tempa
\repeat
\typeout{>>> ignored \the\pst at cnta\space data lines}
\readdata@%
\fi
\endgroup
\let#2\pst at tempg
\global\let\pst at tempg\relax
\ignorespaces}
\makeatother
\begin{document}
\readdata[ignoreLines=2]{\data}{demo9.dat}
%\readdata{\data}{data.dat}
\pspicture(2,4)
\listplot[showpoints=true]{\data}
\psaxes{->}(2,4)
\endpspicture
\end{document}
More information about the PSTricks
mailing list