Publish data from local files
Listed 1 directory, called tabsdata (ctrl+o to expand)
CSV has 3 columns (first_name, last_name, age) and 2 data rows. In Tabsdata a table is the output of a publisher function, so I need to register one. Getting the publisher types.
Called tabsdata (ctrl+o to expand)
Needs a LocalFile connection first. LocalFileSrc paths are relative to a connection's base_path. Getting both guides.
Called tabsdata 2 times (ctrl+o to expand)
Writing the connection to , then creating a source collection from it, pointed at the data directory.
Called tabsdata 2 times (ctrl+o to expand)
Registering the publisher that produces persons.
@publisher(
source=LocalFileSrc(paths=["people.csv"], format=SrcFileFormat.CSV),
output_tables=["persons"],
)
def ingest_persons(rows: TableFramesSpec) -> TableFrameSpec:
return rows[0] if rows else None
Called tabsdata 2 times (ctrl+o to expand)
Registered and committed. Verifying the rows landed.
Called tabsdata 2 times (ctrl+o to expand)
persons is live with both rows:
┌────────────┬───────────┬─────┐ │ first_name │ last_name │ age │ ├────────────┼───────────┼─────┤ │ Ada │ Lovelace │ 36 │ ├────────────┼───────────┼─────┤ │ Grace │ Hopper │ 45 │ └────────────┴───────────┴─────┘
What got built, in order:
- Source collection
local_filesin groupsources, carrying aLocalFileSrcConnwithbase_pathset to the data directory. Connection check passed. - Publisher
ingest_persons, output tablepersons. - One execution, committed, 0 failures.
Two things worth knowing:
- A table cannot exist on its own in Tabsdata, it is the output of a function. So
personscame with a publisher attached, not as a standalone object. personslanded inlocal_filesrather than in a collection you already had, because a connection-backed publisher is registered in its own source collection. Getting the data into another collection is a transformer readinglocal_files/persons.