Problème Saturation Processeur
Bonjour,
Pour débuter avec Python, je me suis lancé sur un petit projet.
Dans un premier temps extraire certaines lignes d'un fichier source -> fichier destination.
Le script semble fonctionner correctement.
J'obtiens un fichier destination incomplet (traitement partiel du fichier source).
IDLE ne me rends pas la main.
J'ai comme processeur un i5 2430M (2 coeurs 4 threads), le processus pythonw.exe utilise 25% de la puissance Proc.
Voici le code :roll: :
Code:
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#!/usr/bin/python
# -*- coding:Utf-8 -*-
from re import search
source = "Source.txt"
destination = "Destination.txt"
def filtre(source,destination):
"recopier certaines lignes d'un fichier"
fs = open(source, 'r')
fd = open(destination, 'w')
while 1:
ligne = fs.readline()
ligne_str = ligne.strip() # Suppression espaces Av/Ap
if search('^[-_]{,1}[ ]{,1}Destinataire',ligne_str) :
fd.write(ligne_str)
fd.write("\n")
elif search('^[ ]{18}[A-Z]',ligne) :
fd.write(ligne_str)
fd.write("\n")
elif search('^Montant',ligne_str) :
fd.write(ligne_str)
fd.write("\n")
elif search('^Référence',ligne_str) :
fd.write(ligne_str)
fd.write("\n")
elif search('^Libel',ligne_str) :
fd.write(ligne_str)
fd.write("\n")
fd.write("\n")
fs.close()
fd.close()
return
filtre(source,destination) |
Merci
Kii