Refactored

This commit is contained in:
2024-10-23 19:29:53 +02:00
parent 2a84291b29
commit 433a29971f
3 changed files with 19 additions and 17 deletions
+5 -8
View File
@@ -5,7 +5,7 @@ from jay_diff import jay_merge_full
BASE = "/media/jens/cifs/jens@moon/projects/we_collect/results"
VIN = 'WVWZZZE1ZMP010760'
NICK = 'alex'
USER = 'alex'
YEAR = 2024
MONTH = 10
DAY = ['20', '21', '22']
@@ -103,7 +103,8 @@ def convert(timestamp_str: str, pattern: str = "%Y-%m-%dT%H:%M:%S.%f%z"):
return result
path = os.path.join(BASE, VIN)
path = os.path.join(BASE, USER)
path = os.path.join(path, VIN)
path = os.path.join(path, str(YEAR))
path = os.path.join(path, str(MONTH))
@@ -123,12 +124,8 @@ for day in day_list:
day_path = os.path.join(month_path, day)
# Sort out files with unknown nickname
file_list = []
for filename in os.listdir(day_path):
if NICK in filename:
file_list.append(filename)
file_list_sorted = sorted(file_list, key=lambda f: convert(f, pattern=f"{VIN}_{NICK}_%Y-%m-%dT%H-%M-%S.json"))
file_list = os.listdir(day_path)
file_list_sorted = sorted(file_list, key=lambda f: convert(f, pattern=f"records_%Y-%m-%dT%H-%M-%S.json"))
print("Files in '", day_path, "' :")
# prints all files
print(file_list_sorted)