Smallcat standalone¶
Use Smallcat without any dependencies.
Setup¶
Install smallcat¶
or
Create an example catalog¶
Create a file named catalog.yaml with the following contents.
# yaml-language-server: $schema=https://raw.githubusercontent.com/DeepKernelLabs/smallcat/refs/heads/main/schemas/catalog.schema.json
entries:
foo:
file_format: csv
connection:
conn_type: fs
extra:
base_path: /tmp/
location: foo.csv
save_options:
header: true
load_options:
header: true
The # yaml-language-server line gives you intellisense in VS code, so it will validate and auto-complete your catalog.
Usage¶
Create main.py¶
Create a python file with the following contents:
import pandas as pd
from smallcat.catalog import Catalog
def get_example_dataset() -> pd.DataFrame:
url = "https://raw.githubusercontent.com/vega/vega-datasets/master/data/seattle-weather.csv"
return pd.read_csv(url, parse_dates=["date"])
def main():
print("Hello from smallcat-local-example!")
catalog = Catalog.from_yaml('catalog.yaml')
catalog.save_pandas('foo', df=get_example_dataset())
df = catalog.load_pandas('foo', where="precipitation > 0")
print(df.head())
if __name__ == "__main__":
main()
Run the file¶
Output: