-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from unb-mds/testando-machine-learning-para-en…
…contrar-valores adicionando ids
- Loading branch information
Showing
4 changed files
with
66,412 additions
and
33,193 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
site/ | ||
myenv/ | ||
backend/venv/ | ||
venv/ | ||
|
||
# Logs | ||
logs | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
import os | ||
# Caminho para o arquivo JSON | ||
file_path = os.path.join(os.getcwd(), 'backend/data_collection/database/data.json') | ||
print(file_path) | ||
# Carregar o JSON existente | ||
with open(file_path, 'r', encoding='utf-8') as file: | ||
data = json.load(file) | ||
|
||
# Adicionar IDs incrementais apenas para itens que não possuem um ID | ||
current_max_id = max((item['id'] for item in data if 'id' in item), default=0) | ||
next_id = current_max_id + 1 | ||
|
||
for item in data: | ||
if 'id' not in item: | ||
item['id'] = next_id | ||
next_id += 1 | ||
|
||
# Salvar o JSON com IDs adicionados | ||
with open(file_path, 'w', encoding='utf-8') as file: | ||
json.dump(data, file, ensure_ascii=False, indent=4) | ||
|
||
print(f"IDs adicionados com sucesso a {next_id - current_max_id - 1} itens.") |
Oops, something went wrong.