-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_and_process_json.py
More file actions
executable file
·35 lines (28 loc) · 1022 Bytes
/
save_and_process_json.py
File metadata and controls
executable file
·35 lines (28 loc) · 1022 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
29
30
31
32
33
34
35
#!/usr/bin/env python3
"""
Save JSON from stdin and process it immediately.
Usage: paste your JSON and pipe to this script, or provide as file argument.
"""
import json
import sys
import subprocess
# Read JSON
if len(sys.argv) > 1:
with open(sys.argv[1], 'r', encoding='utf-8') as f:
json_text = f.read()
else:
json_text = sys.stdin.read()
try:
data = json.loads(json_text)
# Save to file
with open('publications_complete.json', 'w', encoding='utf-8') as f:
json.dump(data, f, indent=2, ensure_ascii=False)
print(f"✓ JSON saved to publications_complete.json")
print(f" Found {sum(len(pubs) for pubs in data.values())} publications across {len(data)} years")
# Now process it
print("\nProcessing publications...")
result = subprocess.run(['python3', 'process_publications.py', 'publications_complete.json'],
capture_output=False)
except json.JSONDecodeError as e:
print(f"✗ JSON Error: {e}")
sys.exit(1)