I read in a text file that is tab delimited, i then have a list for each line, i then index out the first entry of each list, i then write this to a file. code below:
import csv
z = csv.reader(open('output.blast'), delimiter='\t')
k = open('output.fasta', 'w')
for row in z:
print row[1:12]
for i in row[1:12]:
k.write(i+'\t')
When writing to the file it writes it as one long line, i would like a new line to be started after the 11th (last) entry in each list. But i cannot figure out where to put the new line charater
It sounds like you just want it after each row, so put it at the end of the for loop that iterates over the rows:
for row in z:
print row[1:12]
for i in row[1:12]:
k.write(i+'\t')
k.write('\n')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With