dlt.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: str = "*",
kwargs: Optional[Dict[str, Any]] = None,
client_kwargs: Optional[Dict[str, Any]] = None,
incremental: Optional[dlt.sources.incremental[Any]] = None
) -> Tuple[DltResource, ...]
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_urlstr - The url to the bucket.credentialsUnion[FileSystemCredentials, AbstractFileSystem] - The credentials to the filesystem of fsspecAbstractFilesysteminstance.file_globstr, optional - The filter to apply to the files in glob format. by default lists all files in bucket_url non-recursivelykwargs- (Optional[Dict[str, Any]], optional): Additional arguments passed to fsspec constructor ie. dict(use_ssl=True) for s3fsclient_kwargs- (Optional[Dict[str, Any]], optional): Additional arguments passed to underlying fsspec native client ie. dict(verify="public.crt) for botocoreincrementalOptional[dlt.sources.incremental[Any]] - Defines incremental cursor on listed files, withmodification_datebeing the most common choice that returns only files created from the previous run.
Returns:
Tuple[DltResource, ...]: A tuple of resources that are chunked file readers.
filesystem
@decorators.resource(primary_key="file_url",
spec=FilesystemConfigurationResource)
def filesystem(
bucket_url: str = dlt.secrets.value,
credentials: Union[FileSystemCredentials,
AbstractFileSystem] = dlt.secrets.value,
file_glob: str = "*",
files_per_page: int = DEFAULT_CHUNK_SIZE,
extract_content: bool = False,
kwargs: Optional[Dict[str, Any]] = None,
client_kwargs: Optional[Dict[str, Any]] = None,
incremental: Optional[dlt.sources.incremental[Any]] = None
) -> Iterator[List[FileItem]]
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_urlstr - The url to the bucket.credentialsUnion[FileSystemCredentials, AbstractFileSystem] - The credentials to the filesystem of fsspecAbstractFilesysteminstance.file_globstr - The filter to apply to the files in glob format. by default lists all files in bucket_url non-recursivelyfiles_per_pageint, optional - The number of files to process at once, defaults to 100.extract_contentbool, optional - If true, the content of the file will be extracted if false it will return a fsspec file, defaults to False.kwargsOptional[Dict[str, Any]] - Additional arguments passed to fsspec constructor ie. dict(use_ssl=True) for s3fsclient_kwargsOptional[Dict[str, Any]] - Additional arguments passed to underlying fsspec native client ie. dict(verify="public.crt) for botocoreincrementalOptional[dlt.sources.incremental[Any]] - Defines incremental cursor on listed files, withmodification_datebeing the most common choice that returns only files created from the previous run.
Yields:
List[FileItem]- The list of files.