I need to write a python script to iterate calculations on several instances, unfortunately the last test overwrites all those before.
Do you know a way to avoid this? Here is my code, thank you!
import subprocess
import os
from os import listdir
from os.path import isfile, join
import sys
files = [f for f in listdir("data/dataAlea2_50") if isfile(join("data/dataAlea2_50", f))]
K = [2,5]
commande = "g++ -std=c++11 *.cpp -o main -Wall"
subprocess.getoutput(commande)
for file in files:
for k in K:
tmp = subprocess.getoutput("./main" +" " + str(k) + " data/dataAlea2_50/"+ file)
f = open("resulat.txt","w+")
f.write("Voici les resultats pour k = " + str(k) + " et pour les données :" + file )
f.write(tmp)
f.close()