Spaces:
Sleeping

curium-intel / scripts /prep_connections.py
Piers Lyon
Claude Opus 4.7 (1M context)
Add prep_connections.py CLI to dodge HF Spaces upload-size limit
1527bac
Raw History Blame Contribute Delete
1.86 kB
#!/usr/bin/env python3
"""
Prepare a LinkedIn connections XLSX for upload.
The Curium master workbook is ~25 MB and contains 16 sheets (data, pivot
tables, message templates, etc.). HF Spaces' edge proxy can silently drop
the websocket frame for a file that large, so the in-app "Upload
Connections" widget appears to do nothing.
This script:
1. Reads the XLSX
2. Auto-picks the right data sheet (preferring "New Data" with the
movement-tracking columns) using the same logic as the in-app loader
3. Writes a clean CSV next to the original (~3-5 MB)
After running, upload the resulting CSV in the app — it will sail through.
Usage:
venv/bin/python scripts/prep_connections.py <path-to-xlsx>
Example:
venv/bin/python scripts/prep_connections.py \\
"/Users/pierslyon/Downloads/LinkedIn Connection Data - April 2026 Update.xlsx"
"""
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT))
from network_loader import convert_xlsx_to_csv
def main():
if len(sys.argv) != 2:
print(__doc__)
sys.exit(1)
src = Path(sys.argv[1]).expanduser().resolve()
if not src.exists():
print(f"ERROR: file not found: {src}")
sys.exit(2)
if src.suffix.lower() != ".xlsx":
print(f"ERROR: expected .xlsx, got {src.suffix}")
sys.exit(2)
print(f"Reading: {src}")
print(f"Size: {src.stat().st_size / 1024 / 1024:.1f} MB")
out_path = convert_xlsx_to_csv(str(src))
out = Path(out_path)
out_size_mb = out.stat().st_size / 1024 / 1024
print(f"\nWrote: {out}")
print(f"Size: {out_size_mb:.1f} MB")
print()
print("Next: open the app, go to the sidebar Network section, and")
print(" upload this CSV in the Upload Connections widget.")
if __name__ == "__main__":
main()