How to Use dbt seed: Load CSV Data into Your Warehouse
Use
dbt seed to load CSV files from your data directory into your data warehouse as tables. Run dbt seed in your project folder to create or update these tables automatically.Syntax
The basic command to load CSV files as tables is dbt seed. You can add options like --select to load specific seed files or --full-refresh to reload data fully.
dbt seed: Loads all CSV files in thedatafolder.--select <seed_name>: Load only the specified seed file.--full-refresh: Drops and recreates seed tables to refresh data.
bash
dbt seed [--select <seed_name>] [--full-refresh]
Example
This example shows how to load a CSV file named customers.csv placed inside the data folder of your dbt project. Running dbt seed will create a table named customers in your warehouse.
bash
# Place customers.csv inside the 'data' folder # Example customers.csv content: # id,name,email # 1,Alice,alice@example.com # 2,Bob,bob@example.com # Run this command in your dbt project root $ dbt seed # To load only the customers seed: $ dbt seed --select customers # To fully refresh the seed tables: $ dbt seed --full-refresh
Output
Running with dbt=1.x.x
Found 1 seed file:
- customers.csv
Seeding table customers... OK in 0.5s
Done. Seeded 1 table.
Common Pitfalls
Common mistakes when using dbt seed include:
- Placing CSV files outside the
datafolder, so dbt does not find them. - Using incorrect CSV formatting, like missing headers or inconsistent columns.
- Not running
dbt seedafter adding or updating seed files, so tables are not created or refreshed. - Expecting seed tables to update automatically without rerunning the command.
Always check your CSV files and rerun dbt seed after changes.
none
## Wrong: CSV file outside 'data' folder # project_root/customers.csv <-- dbt will NOT load this ## Right: CSV file inside 'data' folder # project_root/data/customers.csv <-- dbt WILL load this ## Wrong: Missing header row in CSV # 1,Alice,alice@example.com # 2,Bob,bob@example.com ## Right: Include header row # id,name,email # 1,Alice,alice@example.com # 2,Bob,bob@example.com
Quick Reference
| Command | Description |
|---|---|
| dbt seed | Load all CSV files in the data folder as tables |
| dbt seed --select | Load only the specified seed file |
| dbt seed --full-refresh | Drop and recreate seed tables to refresh data |
| Place CSV files in 'data' folder | dbt only loads seeds from this folder |
| CSV files must have header row | Headers define table columns |
Key Takeaways
Place CSV files inside the 'data' folder of your dbt project.
Run 'dbt seed' to load CSV files as tables in your warehouse.
Use '--select' to load specific seed files and '--full-refresh' to reload data.
Ensure CSV files have a header row and consistent formatting.
Rerun 'dbt seed' after any changes to your seed files.