Maya batch render log file filter

Maya batch rendering log files are very long, specially when you turn the verbosity level to 4 ( -v 4 ) to display the rendering times. Sometimes, all you want to know is the filename and time per frame of what you are rendering. Here is a little Python script I wrote to filter out just that. You end up with a file that contains only 2 lines per frame rendered, just like this:
Result: c:/my_project/my_file.mb
RC 0.2 info : wallclock 0:00:01.14 for rendering
Here is the Python :
# open source file
f = open('render1.txt', 'r')
# open output file ( if the file doesn't exist, create file )
o = open("out.txt", 'w')
# create an array to store all the lines for the output file
outList = []
# loop through each line
for line in f:
# split the line using the space character
split1 = line.split(" ")
# split the line using the colon character
split2 = line.split(":")
# test the number of words in the line ( if > 5 )
if len(split1) > 5:
# if line starts by "RC"
if split1[0] =="RC":
# if "wallclock" is found
if split1[7] =="wallclock":
# add to the output file Array
outList.append(line)
if split2[0] =="Result":
# add to the output file Array
outList.append(line)
# write the ouput file
o.write(''.join(outList))
# close both files
f.close
o.close
f = open('render1.txt', 'r')
# open output file ( if the file doesn't exist, create file )
o = open("out.txt", 'w')
# create an array to store all the lines for the output file
outList = []
# loop through each line
for line in f:
# split the line using the space character
split1 = line.split(" ")
# split the line using the colon character
split2 = line.split(":")
# test the number of words in the line ( if > 5 )
if len(split1) > 5:
# if line starts by "RC"
if split1[0] =="RC":
# if "wallclock" is found
if split1[7] =="wallclock":
# add to the output file Array
outList.append(line)
if split2[0] =="Result":
# add to the output file Array
outList.append(line)
# write the ouput file
o.write(''.join(outList))
# close both files
f.close
o.close
<< Home