Skip to content

Instantly share code, notes, and snippets.

@zokis
Last active September 17, 2021 16:18
Show Gist options
  • Save zokis/07e8b5623e17e9283b0c0ecf5c0a57d3 to your computer and use it in GitHub Desktop.
Save zokis/07e8b5623e17e9283b0c0ecf5c0a57d3 to your computer and use it in GitHub Desktop.
ed
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