Skip to content
Get started

Getting started

Turn a messy spreadsheet into a clean SQLite database.

In this tutorial, you’ll upload a spreadsheet, convert it into a structured sheet, and download it as a SQLite database and individual CSV files.

  • Python 3.9+ or Node.js 20+
  • A DeepTable API key (get one at deeptable.com)
Terminal window
pip install deeptable
Terminal window
export DEEPTABLE_API_KEY="your-api-key"
Terminal window
curl -O https://docs.deeptable.com/acme_subscriptions.xlsx

Create a file called main.py:

import asyncio
from pathlib import Path
from deeptable import AsyncDeepTable
async def main():
client = AsyncDeepTable()
# Upload your spreadsheet
file = await client.files.upload(
file=Path("acme_subscriptions.xlsx")
)
# Create a structured sheet (this triggers the conversion)
structured_sheet = await client.structured_sheets.create(file_id=file.id)
# Wait for processing to complete
while structured_sheet.status in ("queued", "in_progress"):
await asyncio.sleep(10)
structured_sheet = await client.structured_sheets.retrieve(structured_sheet.id)
# Download as a SQLite database
sqlite = await client.structured_sheets.download(structured_sheet.id, format="sqlite")
await sqlite.write_to_file("acme_subscriptions.sqlite")
if __name__ == "__main__":
asyncio.run(main())

Run it:

Terminal window
python main.py

You uploaded a spreadsheet, and DeepTable:

  1. Analyzed the structure - finding tables, headers, and relationships
  2. Converted the messy spreadsheet data into clean, normalized tables
  3. Returned a SQLite database you or an LLM can query directly

Need individual tables instead of a database? You can download each table separately:

async for table in client.structured_sheets.tables.list(structured_sheet.id):
csv = await client.structured_sheets.tables.download(
structured_sheet_id=structured_sheet.id,
table_id=table.id,
format="csv", # or "parquet"
)
await csv.write_to_file(f"{table.name}.csv")