-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomatizando.py
More file actions
52 lines (32 loc) · 1.08 KB
/
automatizando.py
File metadata and controls
52 lines (32 loc) · 1.08 KB
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
46
47
48
49
50
51
52
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 28 22:08:42 2022
@author: rodrigoborneo
"""
Path = '/Users/rodrigoborneo/Documents/Python/Py_Eng_Cien/Sec_1/Arquivos_teste/teste_'
test_numbers = list(range(1,6))
for i in test_numbers:
file_name = Path + str(i) + '.txt'
print(file_name)
with open(file_name) as f:
linhas = f.readlines()
f.close
#metodo index identifica a posição do primeiro elemento da lista que possui a string especificada
linhas.index('TESTE\n')
#como o 'TESTE\n' está no indice 5, deve buscar tudo que está no 6 para frente
linhas[6:]
arquivo_full = ['ID,A,B\n']
for i in test_numbers:
file_name = Path + str(i) + '.txt'
with open(file_name) as f:
linhas = f.readlines()
f.close
arquivo_full.extend(linhas[7:])
text = ''
for i in enumerate(arquivo_full):
text += arquivo_full[i[0]]
new_file = '/Users/rodrigoborneo/Documents/Python/Py_Eng_Cien/Sec_1/Arquivos_teste/ARQUIVO_FULL.txt'
with open(new_file, 'w') as f:
f.write(text)
f.close