-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat-indexlog.py
More file actions
28 lines (23 loc) · 942 Bytes
/
format-indexlog.py
File metadata and controls
28 lines (23 loc) · 942 Bytes
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
import json
import re
resultados = []
with open('campos_message.json', 'r') as json_file:
data = json.load(json_file)
if 'campos_message' in data:
for campo in data['campos_message']:
id_match = re.search(r'id=(\d+)', campo)
if id_match:
id_numero = id_match.group(1)
id_formatado = id_numero.zfill(4)
value_match = re.search(r'value=(.+)', campo)
if value_match:
value = value_match.group(1)
resultado = f"KC-SERVICES{id_formatado} {value}"
resultados.append(resultado)
else:
resultados.append(f"KC-SERVICES{id_formatado} (sem valor)")
else:
print("Não foram encontrados campos @Message e @LogMessage no arquivo JSON.")
with open('resultados.json', 'w') as json_output:
json.dump(resultados, json_output, indent=4)
print("Os resultados foram exportados para 'resultados.json'.")