pyarrow.fs.FileSelector#
- classpyarrow.fs.FileSelector(base_dir,boolallow_not_found=False,boolrecursive=False)#
Bases:
_WeakrefableFile and directory selector.
It contains a set of options that describes how to search for files anddirectories.
- Parameters:
- base_dir
str The directory in which to select files. Relative paths also work, use‘.’ for the current directory and ‘..’ for the parent.
- allow_not_foundbool, default
False The behavior ifbase_dir doesn’t exist in the filesystem.If false, an error is returned.If true, an empty selection is returned.
- recursivebool, default
False Whether to recurse into subdirectories.
- base_dir
Examples
List the contents of a directory and subdirectories:
>>>selector_1=fs.FileSelector(local_path,recursive=True)>>>local.get_file_info(selector_1)[<FileInfo for 'tmp/alphabet/example.dat': type=FileType.File, size=4>,<FileInfo for 'tmp/alphabet/subdir': type=FileType.Directory>,<FileInfo for 'tmp/alphabet/subdir/example_copy.dat': type=FileType.File, size=4>]
List only the contents of the base directory:
>>>selector_2=fs.FileSelector(local_path)>>>local.get_file_info(selector_2)[<FileInfo for 'tmp/alphabet/example.dat': type=FileType.File, size=4>,<FileInfo for 'tmp/alphabet/subdir': type=FileType.Directory>]
Return empty selection if the directory doesn’t exist:
>>>selector_not_found=fs.FileSelector(local_path+'/missing',...recursive=True,...allow_not_found=True)>>>local.get_file_info(selector_not_found)[]
- __init__(*args,**kwargs)#
Methods
__init__(*args, **kwargs)Attributes
- allow_not_found#
- base_dir#
- recursive#
On this page

