Formatting practices (was: Passing data to system command)

2006-06-19 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Chris Hieronymus <[EMAIL PROTECTED]> wrote: . . . > msg = str(x)+" "+str(y)+"\n" > p1.stdin.write(msg) . . . While Py

Re: Passing data to system command

2006-06-19 Thread Chris Hieronymus
Hi, Holy mackerel, this really works; thanks a lot, guys. I played around a little bit with the suggestions by faulkner and hdante and pieced together the following script. I like this very much because I can write a bunch of data to the pipe, rather than making one big string containing p

Re: Passing data to system command

2006-06-18 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Chris Hieronymus <[EMAIL PROTECTED]> wrote: . . . >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 '{; print $1, $2}' fil

Re: Passing data to system command

2006-06-18 Thread faulkner
import os, subprocess xys = [[1,2],[3,4]] msg = '\n'.join([str(x) + ',' + str(y) for x, y in xys]) os.popen('command', 'w').write(msg) os.popen2('command')[0].write(msg) p = subprocess.Popen('command', stdin=subprocess.PIPE) p.stdin.write(msg) help(subprocess) help(os.popen) help(os.popen3) Ch

Re: Passing data to system command

2006-06-18 Thread hdante
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 Hieronymu

Passing data to system command

2006-06-18 Thread Chris Hieronymus
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 aw