FileRegexBatcher (autotransform.batcher.regex)

The implementation for the RegexBatcher.

class autotransform.batcher.regex.FileRegexBatcher(*, group_by: str, metadata_keys: Dict[str, str] = None)

Bases: Batcher

A Batcher which uses matches from regex on file content to group Items.

group_by

The regex which produces the group by value.

Type:

str

metadata_keys

A mapping from key to a regex that produces values for that key.

Type:

optional, Dict[str, str]

name

The name of the Component.

Type:

ClassVar[BatcherName]

batch(items: Sequence[Item]) List[Batch]

Take filtered Items and group them by regex match values.

Parameters:

items (Sequence[Item]) – The filtered Items to separate.

Returns:

A list of Batches grouped by the extra_data of the Items.

Return type:

List[Batch]

group_by: str
metadata_keys: Dict[str, str]
name: ClassVar[BatcherName] = 'file_regex'