import re
import csv

num = 23

cs1 = open("D:/Result_RE_Revenge" + str(num) + "_checkpoint/logDis.csv", 'w', newline='')
cs2 = open("D:/Result_RE_Revenge" + str(num) + "_checkpoint/logGAN.csv", 'w', newline='')
csvw1 = csv.writer(cs1)
csvw2 = csv.writer(cs2)
w1 = {}
w2 = {}

f = open("D:/Result_RE_Revenge" + str(num) + "_checkpoint/log.txt")
for line in f:
    if 'discrim_loss ' not in line:
        continue
    m1 = re.findall(r'\S+$', line)
    csvw1.writerow(m1)

f.close()
cs1.close()

f = open("D:/Result_RE_Revenge" + str(num) + "_checkpoint/log.txt")
for line in f:
    if 'gen_loss_GAN ' not in line:
        continue
    m2 = re.findall(r'\S+$', line)
    csvw2.writerow(m2)

f.close()
cs2.close()
