added asset to read agency_list.csv and add it to table in gtfs.duckdb

This commit is contained in:
Ben Varick 2025-11-05 18:22:26 -08:00
parent 7791d034ae
commit 2b47a45b8f
Signed by: ben
SSH key fingerprint: SHA256:jWnpFDAcacYM5aPFpYRqlsamlDyKNpSj3jj+k4ojtUo
9 changed files with 44 additions and 4 deletions

18
user_code/gtfs/assets.py Normal file
View 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
""")