1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
#Ouverture fichier input et output
output = open("/home/kevin/Bureau/out_data_test.txt","w")
f1 = open("/home/kevin/Bureau/data_test.txt","r")
l1 = f1.readlines()
#Ligne où A,B,C, et D sont présent et il n'y a pas de point à la place d'un float
for line in l1:
A = re.search("A*=[0-9.,e-]*",line)
B = re.search("B*=[0-9.,e-]*",line)
C = re.search("C*=[0-9.,e-]*",line)
D = re.search("D*=[0-9.,e-]*",line)
#Si on a tous les éléments et que tous ces éléments ont chacun une valeur
if A and D and B and C:
if not (re.search("B*=\.[^0-9]",line) or re.search("C*=\.[^0-9]",line) or re.search("D*=\.[^0-9]",line) or re.search("A*=\.[^0-9]",line)):
if float(A.group(0).split("=")[1]) < 0.05 and float(D.group(0).split("=")[1]) < 0.05 and float(B.group(0).split("=")[1]) < 0.05 and float(C.group(0).split("=")[1]) < 0.05:
output.write(line)
#Si on a des éléments non présents (None où un point comme valeur) et que le autres sont inférieur à 0.05
elif (A is not None and not re.search("A*=\.[^0-9]",line) and float(A.group(0).split("=")[1]) < 0.05 or D is not None and not re.search("D*=\.[^0-9]",line) and float(D.group(0).split("=")[1]) < 0.05 or B is not None and not re.search("B*=\.[^0-9]",line) and float(D.group(0).split("=")[1]) < 0.05 or C is not None and not re.search("C*=\.[^0-9]",line) and float(C.group(0).split("=")[1]) < 0.05):
output.write(line)
#Si aucun n'est présent et qu'on a le mot variant
if not(A or D or B or C) and "variant" in line:
output.write(line) |
Partager