Friday, June 22, 2007


using awk in python for csound

import subprocess
#from os import system
import os
#cmd = """c:\dex_tracker\gawk -f altertime.awk -v time_offset=4#subprocess.Popen.#os.
cmd =["gawk", "-f", "altertime.awk", "-v", "time_offset=4", "-v", "outfile=testdat.sco", "i1.sco"]
os.path = """c://dex_tracker"""last_line = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]#last_line.splitlines()
print last_line

printing to the screen in gawk seems to be unpridictable... to get what you want you have to redirect the output to a file. I havn't tried it with lua to see if the pipe acts better.

{print $0 > outfile} this line uses the > to redirect to an output file.

#usages time_offset outfile
#this is the example command line
#gawk -f altertime.awk -v time_offset=4 -v outfile="testdat.sco" i1.sco
#Begin {BINMODE=rw}

#BINMODE=\"w\" #This tells it to use windows newline charecters instead of unix... very wierd when you redirect to a file it is print that way.
first_letter= substr($1, 1, 1)
{if (first_letter == "i")
$2 = $2 + time_offset}
{print $0}
#{print $0}
#END{print $0}
#first_letter=i{print $0}
{ print $0 > outfile } # print every line

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?