-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8eb3635
commit e04ab10
Showing
4 changed files
with
182 additions
and
200 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from pathlib import Path | ||
from datetime import datetime | ||
|
||
def only_filename(filepath: str): | ||
return Path(filepath).name | ||
|
||
def change_filename(filepath: str, appendix: str = '', suffix: str = ''): | ||
if appendix and not appendix.startswith('_'): appendix = '_' + appendix | ||
if suffix and not suffix.startswith('.'): suffix = '.' + suffix | ||
|
||
p = Path(filepath) | ||
name = p.name.replace(p.suffix, '').split('_')[0] | ||
new_suffix = suffix or p.suffix | ||
return p.with_name(name + appendix + new_suffix) | ||
|
||
def filename_to_date(filename: str): | ||
date_string = filename.split('/')[-1].replace('.nc', '') | ||
return datetime.strptime(date_string, "%Y%m%d").isoformat() + 'Z' | ||
|
||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.