DelfiniFolder

class pydelfini.collections.DelfiniFolder(collection, in_folder, model, core)[source]

Bases: DelfiniItem, FolderMixin

Represents a folder within a collection.

Note that folders cannot be opened as data streams, so the open() method will always return OSError.

Attributes

columns

Item column definitions

created_on

Datetime item was created

id

Item internal ID

metadata

Item metadata

name

Item name

parser

Item parser settings

path

Item fully qualified path

type

Item type (file, folder, dataview, etc.)

collection

Collection that contains this item

in_folder

Folder that contains this item

Parameters:
__getitem__(item_path)

Retrieve an item in this folder.

Relative paths are supported, such as folder_a/folder_b/item_c.

Parameters:

item_path (str)

Return type:

DelfiniItem

__iter__()

Iterate over all items in this folder.

Return type:

Iterator[DelfiniItem]

collection: DelfiniCollection

Collection that contains this item

property columns: list[ItemColumn] | None

Item column definitions

property created_on: datetime

Datetime item was created

folder(folder_name)

Open the named folder.

Parameters:

folder_name (str) – the name of the folder to open

Return type:

DelfiniFolder

get_table(item_path)

Retrieve the tabular contents of an item as a pd.DataFrame.

Parameters:

item_path (str) – The path to the item relative to the current folder. Accepts slashes (‘/’) for items in subfolders.

Return type:

DataFrame

property id: str

Item internal ID

in_folder: FolderMixin

Folder that contains this item

property metadata: dict[str, str]

Item metadata

property name: str

Item name

new_empty_file(file_name)

Create a new, empty file.

Parameters:

file_name (str) – the name of the file to create

Return type:

DelfiniItem

new_folder(folder_name)

Create a new folder.

Parameters:

folder_name (str) – the name of the folder to create

Return type:

DelfiniFolder

Create a new link pointing to a target.

Parameters:
  • target (str) – the full URL of the target

  • link_name (str) – the name of the newly created link. If not provided, the base name of the target will be used.

Return type:

DelfiniItem

open(mode: Literal['rb', 'wb']) BinaryIO[source]
open(mode: Literal['r', 'w']) TextIO

N/A - folders cannot be opened.

Raises: IsADirectoryError always

property parser: ItemParser | None

Item parser settings

property path: str

Item fully qualified path

table()

Retrieve the tabular contents of this item as a pd.DataFrame.

Return type:

DataFrame

property type: ItemType

Item type (file, folder, dataview, etc.)

walk()

Iterate over all items in this folder, and all subfolders.

Return type:

Iterator[DelfiniItem]

write_table(item_path, dataframe, format='csv', **kwargs)

Write a pd.DataFrame to the named item.

Parameters:
  • item_path (str) – The path to the item relative to the current folder. Accepts slashes (‘/’) for items in subfolders.

  • dataframe (DataFrame) – The dataframe to be written.

  • format (Literal['csv', 'parquet']) – One of the supported formats (csv or parquet).

  • **kwargs (Any) – Any other arguments to be passed to the Pandas export function. See the documentation for pd.DataFrame.to_csv() or pd.DataFrame.to_parquet() for valid arguments.

Return type:

None