Passing data to system command
hdante
hdante at gmail.com
Sun Jun 18 17:27:18 EDT 2006
Should be like this:
from subprocess import Popen, PIPE
my_output = file('output1.ps', 'w')
p1 = Popen(["psxy"], stdin = PIPE, stdout=my_output)
p1.stdin.write(my_format(array))
p1.communicate()
my_output.close()
I've never used that, though, please tell us if it worked.
Chris Hieronymus wrote:
> Hi,
>
> I have a bunch of x-y data contained in an array. I would like to
> plot the data using an
> external program (psxy in GMT). The plotting program takes x-y
> couples as standard
> input. How do I get the data into the system call? I used to do
> things in csh and awk,
> i.e., something like
>
> awk '{<some manipulations here>; print $1, $2}' filename | psxy <some
> options> >! output.ps
>
> The reason I'm trying to use python is because the manipulations are
> getting too cumbersome
> in awk. Now I have all the manipulations done in python, but I'm
> missing that last step.
>
> I've tried various things with os.system, popen, and subprocess, but
> so far without success.
> Does anyone know how to do this?
>
> chris
>
>
> ------------------------------------------------------------------------
> -------------------------------------------
> Christoph
> Hieronymus
> christoph.hieronymus at geo.uu.se
> Associate
> Professor
> phone: (+46) 18-471 2383
> Uppsala
> University
> fax: (+46) 18-501 110
> Dept. of Earth Sciences (Geophysics)
> Villavägen 16
> SE-752 36 Uppsala, Sweden
More information about the Python-list
mailing list