formatting - Insert newline character after every line using Python -


i'm trying insert newline character text file after every line.

so if data:

dose    atra_minus_tet  tet 0.001   5.100033162 0 0.001967886 9.651369961 0 0.003926449 16.72520921 0 

i want:

dose    atra_minus_tet  tet  0.001   5.100033162 0  0.001967886 9.651369961 0  0.003926449 16.72520921 0 

my code:

def prepare_steady_state_data(self,data_file):     open(data_file) f:         lines= [line+'\n' line in f.readlines()]      open(data_file[:-4]+'_for_ss_fit.txt','w') f:         f.write(str(lines)) 

the problem writes string literally, so:

['dose,cyp26(atra_plus_tet),tet\n\n', '0.001,26.67599946,1\n\n', '0.001006932,26.89620879,1\n\n', '0.001013911,27.117882,1\n\n', '0.001020939,27.34102614,1\n\n'] 

how change code desired format in output text file?

with thanks,

ciaran

with open(data_file) source:     open(data_file[:-4]+'_for_ss_fit.txt','w') output:         line in source:             f.write(line+'\n') 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -