Last active
June 4, 2021 18:36
-
-
Save MaxMorais/03ae549883eadb0dc849bcc2ab7e2c48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
Linha = namedtuple('Linha', ('DAtras')) | |
novo_conteudo = [] | |
with open('./meu-arquivo.txt') as f: | |
conteudo = f.readlines() | |
inicio_encontrado = False | |
while not inicio_encontrado: | |
linha = conteudo.pop(0) | |
if 'Histórico de pagamento' not in linha: | |
continue | |
else: | |
inicio_encontrado = True | |
for linha in conteudo: | |
if '--' in linha: | |
continue | |
elif not linha: | |
continue | |
linha = list(filter(None, map(lambda valor: valor.strip(), linha.split('|')))) | |
if not linha: | |
continue | |
try: | |
novo_conteudo.append( | |
Linha(int(linha[1]) if '-' not in linha[1] else (int(linha[1].replace('-', '')) * -1)) | |
) | |
except ValueError as e: | |
continue | |
for linha in novo_conteudo: | |
print(linha._asdict()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment