-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_folders.py
More file actions
39 lines (32 loc) · 1.41 KB
/
process_folders.py
File metadata and controls
39 lines (32 loc) · 1.41 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
import json
import os
folder1_path = 'folder1'
folder2_path = 'folder2'
folder1_conversations = {}
if os.path.exists(folder1_path):
for filename in os.listdir(folder1_path):
if filename.endswith('.json'):
file_path = os.path.join(folder1_path, filename)
with open(file_path, 'r') as f:
try:
data = json.load(f)
conversation_id = data.get('conversation_id')
if conversation_id:
folder1_conversations[conversation_id] = data
except json.JSONDecodeError:
print(f"Error decoding JSON from {file_path}")
folder2_conversations = {}
if os.path.exists(folder2_path):
for filename in os.listdir(folder2_path):
if filename.endswith('.json'):
file_path = os.path.join(folder2_path, filename)
with open(file_path, 'r') as f:
try:
data = json.load(f)
conversation_id = data.get('conversation_id')
if conversation_id:
folder2_conversations[conversation_id] = data
except json.JSONDecodeError:
print(f"Error decoding JSON from {file_path}")
shared_conversation_ids = set(folder1_conversations.keys()).intersection(folder2_conversations.keys())
print(f"Shared conversation IDs: {list(shared_conversation_ids)}")