TypeError: coercing to Unicode: need string or buffer
You're trying to open each file twice! First you do:
infile=open('110331_HS1A_1_rtTA.result','r')
and then you pass infile
(which is a file object) to the open
function again:
with open (infile, mode='r', buffering=-1)
open
is of course expecting its first argument to be a file name, not an opened file!
Open the file once only and you should be fine.
For the less specific case (not just the code in the question - since this is one of the first results in Google for this generic error message. This error also occurs when running certain os command with None argument.
For example:
os.path.exists(arg)
os.stat(arg)
Will raise this exception when arg is None.