Shortcuts

FileLister

class torchdata.datapipes.iter.FileLister(root: Union[str, Sequence[str], IterDataPipe] = '.', masks: Union[str, List[str]] = '', *, recursive: bool = False, abspath: bool = False, non_deterministic: bool = False, length: int = - 1)

Given path(s) to the root directory, yields file pathname(s) (path + filename) of files within the root directory. Multiple root directories can be provided (functional name: list_files).

Parameters:
  • root – Root directory or a sequence of root directories

  • masks – Unix style filter string or string list for filtering file name(s)

  • recursive – Whether to return pathname from nested directories or not

  • abspath – Whether to return relative pathname or absolute pathname

  • non_deterministic – Whether to return pathname in sorted order or not. If False, the results yielded from each root directory will be sorted

  • length – Nominal length of the datapipe

Example

>>> # xdoctest: +SKIP
>>> from torchdata.datapipes.iter import FileLister
>>> dp = FileLister(root=".", recursive=True)
>>> list(dp)
['example.py', './data/data.tar']

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources