From 1f4ec77467b12f50b1859c6f16b862e33cfcffaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Melan=C3=A7on?= Date: Tue, 25 May 2021 15:57:52 -0400 Subject: [PATCH] Gather all csv files in provided directory --- pomodoro_to_harvest.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pomodoro_to_harvest.py b/pomodoro_to_harvest.py index 5762933..34bd1ed 100644 --- a/pomodoro_to_harvest.py +++ b/pomodoro_to_harvest.py @@ -1,11 +1,27 @@ import pandas as pd import numpy as np +import glob import re import sys # Import our local settings management. import settings -timelog = pd.read_csv(settings.pomodoro_logfile()) +# This works for one file: +# timelog = pd.read_csv(settings.pomodoro_logfile()) + +# For multiple files: +path = settings.pomodoro_logpath() +all_files = glob.glob(path + "/*.csv") + +li = [] + +for filename in all_files: + df = pd.read_csv(filename, index_col=None, header=0) + li.append(df) + +timelog = pd.concat(li, axis=0, ignore_index=True) + +timelog = timelog.dropduplicates(inplace=True) # Dump bad data. The real solution here is to get rid of the damned 'Cancel' # button on the Pomodoro Prompt dialog, but i don't know how to do that, so we