Exporting Data
Terminal operations trigger chain execution and produce output. Export methods get data out of DataChain into formats that downstream tools consume.
DataFrames and Files
Export Placement Strategies
When exporting to storage, the placement parameter controls how file paths are constructed:
filename: retains only the original filename, discards directoriesfilepath: preserves the relative directory structurefullpath: prefixes paths with the storage hostetag: uses the file ETag with original extension (guarantees uniqueness)
PyTorch DataLoader Integration
DataChain exports directly to PyTorch datasets:
Train/Test Split
Each split is a full chain that can be saved, exported, or fed to to_pytorch().
Extracting Results in Python
For processing chain results, prefer map()/gen() over extracting and looping; they preserve parallelism and lineage.
Writing to Databases
to_database() writes chain results to any SQLAlchemy-compatible database:
Rows are written in batches (default 10,000). The on_conflict parameter controls duplicate handling: "ignore" skips, "update" overwrites. column_mapping renames columns and can exclude columns by mapping them to None.
Complete Example: Data Curation Pipeline
Read files, enrich with a local model, filter, and export the results: