규칙 적용 재추적
This commit is contained in:
30
tools/delete_error_and_empty_files.py
Normal file
30
tools/delete_error_and_empty_files.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
import json
|
||||
|
||||
dir_path = "result/gemma3-upstage/"
|
||||
files_to_delete = []
|
||||
|
||||
for filename in os.listdir(dir_path):
|
||||
if filename.endswith(".json"):
|
||||
file_path = os.path.join(dir_path, filename)
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
|
||||
if "result" in data:
|
||||
result_data = data["result"]
|
||||
# Check if result is an empty dictionary or contains "Error" key
|
||||
if not result_data or "Error" in result_data:
|
||||
files_to_delete.append(file_path)
|
||||
|
||||
except (json.JSONDecodeError, KeyError) as e:
|
||||
print(f"Error processing file {filename}: {e}")
|
||||
|
||||
for file_path in files_to_delete:
|
||||
try:
|
||||
os.remove(file_path)
|
||||
print(f"Deleted: {os.path.basename(file_path)}")
|
||||
except OSError as e:
|
||||
print(f"Error deleting file {os.path.basename(file_path)}: {e}")
|
||||
|
||||
print(f"\nTotal deleted files: {len(files_to_delete)}")
|
||||
Reference in New Issue
Block a user