|
import json |
|
|
|
|
|
with open('your_json_file_here.json', 'r') as json_file: |
|
data = json.load(json_file) |
|
|
|
|
|
minimum_average_token_length = 125 |
|
minimum_conversations_length = 10 |
|
|
|
|
|
filtered_items = [ |
|
item for item in data |
|
if item.get('average_token_length', 0) >= minimum_average_token_length |
|
and len(item.get('conversations', [])) >= minimum_conversations_length |
|
] |
|
|
|
|
|
with open('filtered_json_file.json', 'w') as filtered_json_file: |
|
json.dump(filtered_items, filtered_json_file, indent=4) |
|
|
|
|
|
for i, item in enumerate(filtered_items): |
|
print(f"Filtered Item {i + 1} - Average Token Length: {item.get('average_token_length')}, Conversations Length: {len(item.get('conversations', []))}") |