2017-10-11 2 views
0

Je suis this tutorial here pour séparer et écrire un fichier texte délimité, mais seulement obtenir un fichier en sortie. Est-ce un problème python2 -> 3? Aidez-moi, s'il vous plaît.Séparer et écrire des fichiers uniques à partir d'un texte délimité

filename = ('file path') 

with open(filename) as Input: 
    op = '' 
    start = 0 
    count = 1 
    for x in Input.read().split("\n"): 
     if (x == 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'): 
      if (start == 1): 
       with open(str(count) + '.txt', 'w') as Output: 
        Output.write(op) 
        Output.close() 
        op = '' 
        count = + 1 
      else: 
       start = 1 
    Input.close() 

Répondre

0

Vous avez toujours count = 1.

Modifier cette ligne:

count = + 1 

à

count += 1