path_resource_data

Warning

🚧 Sprout is still in active development and evolving quickly, so the documentation and functionality may not work as described and could undergo substantial changes 🚧

core.path_resource_data(package_id: int, resource_id: int)

Gets the absolute path to the specified resource’s data (i.e., parquet) file.

Parameters

package_id : int

ID of the package.

resource_id : int

ID of the resource.

Returns

Path

The absolute path the specified resource’s data file.

Examples

import os
import tempfile

import seedcase_sprout.core as sp

# Create a temporary directory for the example
with tempfile.TemporaryDirectory() as temp_dir:
    os.environ["SPROUT_GLOBAL"] = temp_dir

    # Create a package and resource structure first
    sp.create_package_properties(
        properties=sp.example_package_properties(),
        path=sp.path_packages()
    )

    # TODO: Update after converting to "local-first"
    # sp.create_resource_structure(path=sp.path_resources(package_id=1))
    # sp.write_resource_data_to_raw(
    #   package_id=1,
    #   resource_id=1,
    #   data="path/to/data.csv")

    # sp.write_resource_parquet(
    #     raw_files=sp.path_resource_raw_files(package_id=1, resource_id=1),
    #     path=sp.path_resource_data(package_id=1, resource_id=1))

    # Get the path to the resource data
    # sp.path_resource_data(package_id=1, resource_id=1)
PosixPath('/tmp/tmp7f8yjmmv/packages/datapackage.json')