I am writing a text file with the following code(pl in the code is a list of lists):
out_file = open("par.txt", 'w')
out_file.write("id\ttrans_id\ttype\tstatus\tname\ttrans_type\ttrans_status\ttrans_name\n")
for lst in pl:
out_file(lst[0].split()[1],"\t",lst[1].split()[1],"\t",lst[2].split()[1],"\t",lst[3].split()[1],"\t",lst[4].split()[1],"\t",lst[5].split()[1],"\t",lst[6].split()[1],"\t",lst[7].split()[1])
out_file.close()
BUT it gives this error:
Traceback (most recent call last):
File "test.py", line 25, in <module>
out_file(lst[0].split()[1],"\t",lst[1].split()[1],"\t",lst[2].split()[1],"\t",lst[3].split()[1],"\t",lst[4].split()[1],"\t",lst[5].split()[1],"\t",lst[6].split()[1],"\t",lst[7].split()[1])
TypeError: 'file' object is not callable
Try this:
Example Output:
You need to change the loop to something like: