I have a text file which I read in and then I extract the data I require and try sending it to different new text file, but only the first line gets into the new text file.
import csv
f = open('C:\\Users\\c\\Documents\\DCX.txt')
next(f)
csv_f=csv.reader(f, delimiter='\t')
for row in csv_f:
if 'DCX3520E' in row[0] and 'NULL' not in row[6]:
with open("out.txt","w") as f1:
dcx = row[0] + " " + row[6]
aa = dcx[9:]
print(aa)
f1.writelines(aa)