# xlwings Lite Data Importer

Import any file format into xlwings Lite via cloud links. CSV, Parquet, DuckDB, SQLite, JSON, PDF, Images, ZIP - from Google Drive, Dropbox, GitHub, and custom URLs. Auto-converts data files to DuckDB for SQL analytics. Supports token access for private files.

## Links
- App: https://app.tigzig.com/xlwings-data-importer
- GitHub (all xlwings Lite code): https://github.com/amararun/xlwings-lite-apps-codes-docs
- Cloudflare Workers (CORS proxy): https://github.com/amararun/xlwings-lite-apps-codes-docs/tree/main/cloudflare-workers

## Tags
python-in-excel, xlwings-lite, duckdb

## Download
- Excel Workbook: https://www.tigzig.com/files/xlwings/XLWINGS_LITE_DATA_IMPORTER_V2_17JAN2025_C.xlsx

## Architecture

```
Your Files (CSV, Parquet, DuckDB, SQLite, JSON, PDF, ZIP)
  → Upload to Cloud (Google Drive, Dropbox, GitHub, DuckIt)
    → xlwings Lite (Paste URL → Auto-detect → Load into DuckDB → Run SQL in Excel)
```

### Three Access Modes

**Shareable Link Access (Simple Setup)**
- Paste any public or shareable link
- Cloud sources: GitHub Releases, Google Drive, Dropbox, DuckIt URLs
- Uses CORS proxy for cross-origin downloads
- Handles large files (tested up to 1.5 GB, 20M+ rows)
- Intelligent file type and delimiter auto-detection
- Multi-level detection: URL extension → Content-Disposition header → magic bytes

**Token Access (Fully Private)**
- Import from private cloud storage using OAuth tokens or PATs
- Dropbox: OAuth refresh token → direct API access (no proxy)
- Google Drive: OAuth refresh token → direct API access (no proxy)
- GitHub: Personal Access Token (PAT) → auth proxy for private repos
- Tokens stored as xlwings Lite environment variables
- One-time setup, then just specify file path

**Raw File Import**
- Download any file type as-is without DuckDB conversion
- PDF, images, ZIP, Excel - saved to browser temp directory
- Available for both Shareable Link and Token Access modes

### Technical Details
- Runs Python via xlwings Lite (Pyodide/WebAssembly)
- SQLite auto-conversion via Python sqlite3 module
- JSON/NDJSON auto-detection via magic bytes
- DuckDB Python integration for unified SQL analytics across all file types

## Setup Guides
- OAuth Token Setup Guide: https://www.tigzig.com/files/xlwings/text-guides/TOKEN_ACCESS_SETUP_GUIDE.txt
- Cloudflare Worker CORS Proxy Guide: https://www.tigzig.com/files/xlwings/text-guides/CLOUDFLARE_WORKER_SETUP_GUIDE.txt

## Resources
- xlwings Lite: https://lite.xlwings.org
- xlwings Documentation: https://docs.xlwings.org/en/latest/
- xlwings_utils by Ruud van der Ham: https://github.com/salabim/xlwings_utils (OAuth token patterns - basis for Token Access feature)
