Created
December 19, 2022 16:17
-
-
Save IamPhytan/c9084c2273bd02ca3ada502979d10c50 to your computer and use it in GitHub Desktop.
Filepath : Pathlib-like path management for Python 3.7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import path | |
class FilePath: | |
def __init__(self, complete_path): | |
self.folder, self.filename = path.split(complete_path) | |
self.filestem, self.ext = path.splitext(self.filename) | |
self.path = complete_path | |
self.csv_type = self.filestem.rsplit("_", 1)[-1] | |
def __repr__(self): | |
info = { | |
"folder": self.folder, | |
"name": self.filename, | |
"stem": self.filestem, | |
"ext": self.ext, | |
"path": self.path, | |
} | |
return "{folder} | {name} | {stem} | {ext} | {path}".format(**info) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment