--- title: Getting started | DeepTable description: 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. ## Prerequisites - **Python 3.9+** or **Node.js 20+** - A DeepTable API key (get one at [deeptable.com](https://www.deeptable.com)) ## 1. Install the SDK - [Python](#tab-panel-0) - [TypeScript](#tab-panel-1) Terminal window ``` pip install deeptable ``` Terminal window ``` npm install @deeptable/deeptable ``` ## 2. Set your API key Terminal window ``` export DEEPTABLE_API_KEY="your-api-key" ``` ## 3. Download an example spreadsheet Terminal window ``` curl -O https://docs.deeptable.com/acme_subscriptions.xlsx ``` ## 4. Run this script - [Python](#tab-panel-2) - [TypeScript](#tab-panel-3) 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 ``` Create a file called `main.ts`: ``` import DeepTable from "@deeptable/deeptable"; import * as fs from "fs"; const client = new DeepTable(); async function main() { // Upload your spreadsheet const file = await client.files.upload({ file: fs.createReadStream("acme_subscriptions.xlsx"), }); // Create a structured sheet (this triggers the conversion) let structuredSheet = await client.structuredSheets.create({ file_id: file.id, }); // Wait for processing to complete while (structuredSheet.status === "queued" || structuredSheet.status === "in_progress") { await new Promise((resolve) => setTimeout(resolve, 10000)); structuredSheet = await client.structuredSheets.retrieve(structuredSheet.id); } if (structuredSheet.status === "failed") { throw new Error("Processing failed"); } // Download as a SQLite database const response = await client.structuredSheets.download(structuredSheet.id, { format: "sqlite", }); const buffer = Buffer.from(await response.arrayBuffer()); fs.writeFileSync("acme_subscriptions.sqlite", buffer); } main(); ``` Run it: Terminal window ``` npx tsx main.ts ``` ## What just happened? 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 ## Download as CSV or Parquet Need individual tables instead of a database? You can download each table separately: - [Python](#tab-panel-4) - [TypeScript](#tab-panel-5) ``` 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") ``` ``` for await (const table of client.structuredSheets.tables.list(structuredSheet.id)) { const response = await client.structuredSheets.tables.download( structuredSheet.id, table.id, { format: "csv" } // or "parquet" ); const buffer = Buffer.from(await response.arrayBuffer()); fs.writeFileSync(`${table.name}.csv`, buffer); } ``` ## Next steps - Explore the [API Reference](/api/index.md) to see all available endpoints