Root-agnostic filepath generation
Project description
Purpose
The filepaths module is designed to ease file path navigation in python scripts.
Installation
python -m pip install filepaths
Use
from filepaths import paths
paths = paths(1)
for file in paths.data.filepaths:
pd.read_csv(file)
pass
or
from filepaths import Root
root = Root(1).paths()
for file in root.data.filepaths:
pd.read_csv(file)
pass
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
.
Alternitavely, one can call the function paths()
with the same paramaters as the class Root
which will return a addict dictionary directly.
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.
Either Root
or paths
dictionary has a key for every directory in root. Every directory, including root
, has keys for 'files', 'dirs', 'path',
and 'filepaths'
. The values are either another nested dictionary for the dirs
, or:
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 Distribution
Built Distributions
Hashes for filepaths-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a7526c50355be3fd174bec51cb0de502e15cc9af58cceb448a41485911e0d27 |
|
MD5 | 6e130cafca2d453fadadeb04803c8a11 |
|
BLAKE2b-256 | cc924f3787179ab3fa46e9fc16f5d71e1b08ad3a89706412d184fb925f1c8a08 |
Hashes for filepaths-0.0.7-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2aaaf0fe66b6de3dc64f2acc8861a46dae8f1915a5a93e3abe895481ee82545c |
|
MD5 | 0eedde8cc30c095bdb99aba577ae2e73 |
|
BLAKE2b-256 | 15e971272e048fd3303c4f007a6723656bba7f32b48dad5887e19e9e9dc6f911 |