Documentation Index
Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
Use this file to discover all available pages before exploring further.
Problem
You have data in CSV or Excel files that you want to process with AI models, add computed columns to, or combine with other data sources.Solution
What’s in this recipe:- Import CSV files directly into tables
- Import from Pandas DataFrames
- Handle different data types
pxt.create_table() with a source parameter to create a table
from a CSV file, or insert DataFrame rows into an existing table.
Setup
Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘import_demo’.
<pixeltable.catalog.dir.Dir at 0x141eca110>
Import CSV directly
Usecreate_table with source to create a table from a CSV file:
Created table ‘population’.Inserting rows into `population`: 0 rows [00:00, ? rows/s] Inserting rows into `population`: 234 rows [00:00, 9032.63 rows/s] Inserted 234 rows with 0 errors.
Import from Pandas DataFrame
You can also create a DataFrame first and insert it:Created table ‘users’.Inserting rows into `users`: 0 rows [00:00, ? rows/s] Inserting rows into `users`: 3 rows [00:00, 923.31 rows/s] Inserted 3 rows with 0 errors. 3 rows inserted, 6 values computed.
Explanation
Source types supported: Type inference: Pixeltable automatically infers column types from CSV data. You can override types usingschema_overrides.
Large files:
For very large CSV files, consider:
- Using
create_table(source=...)which streams data - Importing in batches if memory is limited