added asset to read agency_list.csv and add it to table in gtfs.duckdb
This commit is contained in:
parent
7791d034ae
commit
2b47a45b8f
9 changed files with 44 additions and 4 deletions
18
user_code/gtfs/assets.py
Normal file
18
user_code/gtfs/assets.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import pandas as pd
|
||||
from dagster import asset
|
||||
from dagster_duckdb import DuckDBResource
|
||||
|
||||
|
||||
@asset
|
||||
def agency_list(duckdb: DuckDBResource) -> None:
|
||||
"""Load agency list from CSV into DuckDB."""
|
||||
|
||||
# Read the CSV (path is relative to container working directory)
|
||||
df = pd.read_csv('data/gtfs/agency_list.csv')
|
||||
|
||||
# Write to DuckDB
|
||||
with duckdb.get_connection() as conn:
|
||||
conn.execute("""
|
||||
CREATE TABLE IF NOT EXISTS agency_list AS
|
||||
SELECT * FROM df
|
||||
""")
|
||||
Loading…
Add table
Add a link
Reference in a new issue