I’m trying to get a programme of mine to write its output to a file. It does this in a loop, but I think that it overwrites what is in the file each time, instead of adding to it. Here is the relevant code:
g = open('mjd.txt','a')
for i in range(len(new_y)):
os.system('vap -c "mjd" {0} > mjd.txt'.format(new_y[i]))
where vap is the command from another programme which outputs one line.
After looping though, there is only one line in my “mjd.txt” file, and I want there to be several.
Any help would be great. Thank you.
Change the line to the following to append. Can’t think of what the name of the > and >> are at the moment.