Saturday, September 16, 2006


maybe working extractCsdInstrument code in python

def extractCsdInstrument (input_File_Name, output_File_Name, instr_number):

"takes an .csd input file and grabs instr_number instrument and creates output_File_Name"
f = open (input_File_Name , 'r') #opens file passed in to read
f2 = open (output_File_Name, 'w') #opens file passed in to write
instr_yes = 'false' #set flag to false
for line in f: #for through all the lines
if "instr" in line: #look for instr in the file
if instr_yes = 'true' : #check to see if this ends the instr block
break #exit the block
reline = re.line.split('instr', /d$) #error probily split instr and /d (decimal number into parts) $ for end of line
number = int(reline[1]) #convert to a number maybe not important
if number = instr_number #check to see if it is the instr passed to function
instr_yes = "true" #change flag to true because this is the instr we want
if instr_yes = "true": #start of code to copy to another file
f2.write(f.line) #write line to output file

f.close #close input file
f2.close #close output file

I am sorta getting iratated at it but hopefully this works without to much debugging

Comments: Post a Comment

<< Home

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