Edit page in Livemark
(2022-09-19 18:33)

Catalog Class

Catalog is a set of data packages.

Creating Catalog

We can create a catalog providing a list of data packages:

from frictionless import Catalog, Package

catalog = Catalog(packages=[Package('tables/*')])

Describing Catalog

Usually Catalog is used to describe some external set of datasets like a CKAN instance or a Github user or search. For example:

from frictionless import Catalog

catalog = Catalog('https://demo.ckan.org/dataset/')
print(catalog)

Package Management

The core purpose of having a catalog is to provide an ability to have a set of packages. The Catalog class provides useful methods to manage packages:

from frictionless import Catalog

catalog = Catalog('https://demo.ckan.org/dataset/')
catalog.package_names
catalog.has_package
catalog.add_package
catalog.get_package
catalog.clear_packages

Saving Descriptor

As any of the Metadata classes the Catalog class can be saved as JSON or YAML:

from frictionless import Package

catalog = Catalog('https://demo.ckan.org/dataset/')
catalog.to_json('datacatalog.json') # Save as JSON
catalog.to_yaml('datacatalog.yaml') # Save as YAML

Reference

Catalog (class)

Catalog (class)

Catalog representation

Signature

(source: Optional[Any] = None, *, control: Optional[Control] = None, name: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, packages: List[Union[Package, str]] = [], basepath: Optional[str] = None)

Parameters

  • source (Optional[Any])
  • control (Optional[Control])
  • name (Optional[str])
  • title (Optional[str])
  • description (Optional[str])
  • packages (List[Union[Package, str]])
  • basepath (Optional[str])

catalog.name (property)

A short url-usable (and preferably human-readable) name. This MUST be lower-case and contain only alphanumeric characters along with “.”, “_” or “-” characters.

Signature

Optional[str]

catalog.title (property)

A short url-usable (and preferably human-readable) name. This MUST be lower-case and contain only alphanumeric characters along with “.”, “_” or “-” characters.

Signature

Optional[str]

catalog.description (property)

A short url-usable (and preferably human-readable) name. This MUST be lower-case and contain only alphanumeric characters along with “.”, “_” or “-” characters.

Signature

Optional[str]

catalog.packages (property)

A short url-usable (and preferably human-readable) name. This MUST be lower-case and contain only alphanumeric characters along with “.”, “_” or “-” characters.

Signature

List[Package]

catalog.basepath (property)

A short url-usable (and preferably human-readable) name. This MUST be lower-case and contain only alphanumeric characters along with “.”, “_” or “-” characters.

Signature

Optional[str]

catalog.package_names (property)

Return names of packages

Signature

List[str]

catalog.add_package (method)

Add new package to the package

Signature

(package: Union[Package, str]) -> Package

Parameters

  • package (Union[Package, str])

catalog.clear_packages (method)

Remove all the packages

catalog.get_package (method)

Get package by name

Signature

(name: str) -> Package

Parameters

  • name (str)

catalog.has_package (method)

Check if a package is present

Signature

(name: str) -> bool

Parameters

  • name (str)

catalog.infer (method)

Infer catalog's metadata

Signature

(*, sample=True, stats=False)

Parameters

  • sample
  • stats

catalog.remove_package (method)

Remove package by name

Signature

(name: str) -> Package

Parameters

  • name (str)

catalog.set_package (method)

Set package by name

Signature

(package: Package) -> Optional[Package]

Parameters

  • package (Package)
It's a beta version of Frictionless Framework (v5). Read Frictionless Framework (v4) docs for a version that is currently installed by default by pip.