Skip to main content
Version: devel

sources.filesystem

Reads files in s3, gs or azure buckets using fsspec and provides convenience resources for chunked reading of various file formats

readers

@decorators.source(_impl_cls=ReadersSource,
spec=FilesystemConfigurationResource)
def readers(bucket_url: str = dlt.secrets.value,
credentials: Union[FileSystemCredentials,
AbstractFileSystem] = dlt.secrets.value,
file_glob: Optional[str] = "*") -> Tuple[DltResource, ...]

[view_source]

This source provides a few resources that are chunked file readers. Readers can be further parametrized before use read_csv(chunksize, **pandas_kwargs) read_jsonl(chunksize) read_parquet(chunksize)

Arguments:

  • bucket_url str - The url to the bucket.
  • credentials FileSystemCredentials | AbstractFilesystem - The credentials to the filesystem of fsspec AbstractFilesystem instance.
  • file_glob str, optional - The filter to apply to the files in glob format. by default lists all files in bucket_url non-recursively

filesystem

@decorators.resource(primary_key="file_url",
spec=FilesystemConfigurationResource,
standalone=True)
def filesystem(bucket_url: str = dlt.secrets.value,
credentials: Union[FileSystemCredentials,
AbstractFileSystem] = dlt.secrets.value,
file_glob: Optional[str] = "*",
files_per_page: int = DEFAULT_CHUNK_SIZE,
extract_content: bool = False) -> Iterator[List[FileItem]]

[view_source]

This resource lists files in bucket_url using file_glob pattern. The files are yielded as FileItem which also provide methods to open and read file data. It should be combined with transformers that further process (ie. load files)

Arguments:

  • bucket_url str - The url to the bucket.
  • credentials FileSystemCredentials | AbstractFilesystem - The credentials to the filesystem of fsspec AbstractFilesystem instance.
  • file_glob str, optional - The filter to apply to the files in glob format. by default lists all files in bucket_url non-recursively
  • files_per_page int, optional - The number of files to process at once, defaults to 100.
  • extract_content bool, optional - If true, the content of the file will be extracted if false it will return a fsspec file, defaults to False.

Returns:

  • Iterator[List[FileItem]] - The list of files.

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.