Root-agnostic filepath generation
Project description
filepaths
Purpose
The filepaths module is designed to ease file path navigation in python scripts.
Use
from filepaths import Root
root = Root(depth=1).paths()
for file in root.data.files:
pd.read_csv(file)
The root object builds a dictionary of files and directories starting in either the current directory, or depth
levels up. By default, hidden files and folder are ignored, but ignore_hidden
can be set to False
.
The .path()
method returns an addict dictionary. This dictionary inherits the standard dictionary class; it can be accessed with either root[data][files]
or root.data.files
.
The keys 'files', 'dirs', 'path',
and 'filepaths'
are reserved for the dictionary: if there are directories with these names in any of the children directories, an error will be thrown.
Here, root
has a key for every directory in root. Every directory, including root
, has keys for 'files', 'dirs', 'path',
and 'filepaths'
.
root.example.path
returns the absolute path to theexample/
as a string.root.example.dirs
returns a list of the child directories inexample/
.root.example.files
returns a list of the filenames, as strings, for every file inexample/
.root.example.filepaths
returns a list of the absolute paths, as strings, to every file inexample/
.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for filepaths-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d74dc958940d921e92eed408229e6a8a7523171c4456ba9c9f98b6ac365aeeb8 |
|
MD5 | cb69ac09a37847bcb43ececc1466e81a |
|
BLAKE2b-256 | d172d5ef32b5f51761e2c93a9cd98a3748225edd9887936d97ba4fa5dce7a262 |