Last active
September 17, 2021 16:18
-
-
Save zokis/07e8b5623e17e9283b0c0ecf5c0a57d3 to your computer and use it in GitHub Desktop.
ed
This file contains hidden or 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
with open('ed.txt', 'r') as f: # abre o arquivo de oriem | |
with open('ed_out.txt', 'w') as fo: # abre o arquivo de saida | |
for n, linha in enumerate(f.readlines(), 1): # itera nas linhas adicionando o numero da lina | |
if n % 2 == 0: # se a linha for par o final é nova linha | |
end = '\n' | |
else: # se for impar é um tab | |
end = '\t' | |
out_line = linha.replace('\n', '') # tira a nova linha das linhas lidas no arquivo de entrada | |
fo.write(out_line + end) # escreve no arquivo a linha mais o final |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment