Have been working on this tiny simple code for an hour and can't figure out how to fix it. The code does this:
Reads in 3-column, tab-delimited data file
Adds "1000" in the fourth column to every line
Writes out the 4-column file
def columns(infile, outfile): f = open(infile,'r') o = open(outfile,'w') temp =  #Store an empty list for line in f: line=line.strip() line=line.split('\t') line.insert(3, "1000") temp.append(line) # print temp o.write('\n'.join(temp)) print "See %s" % (outfile) f.close() o.close()
And getting the error:
TypeError: sequence item 0: expected string, list found
I realize I'm trying to writeout a list and it is barking, but what can I do to fix it? I had an almost identical code run which only had one column of data to work with, but with multiple columns, it won't writeout.