From d952f113504d923ebad4463e06ccbea16c8348bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Melan=C3=A7on?= Date: Fri, 28 May 2021 14:21:52 -0400 Subject: [PATCH] Make one CSV logfile vs directory an option determined via settings.ini Default to directory. --- pomodoro_to_harvest.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pomodoro_to_harvest.py b/pomodoro_to_harvest.py index 327c928..807789e 100644 --- a/pomodoro_to_harvest.py +++ b/pomodoro_to_harvest.py @@ -12,20 +12,21 @@ if hasattr(sys, 'ps1'): else: debug = False -# This works for one file: -timelog = pd.read_csv(settings.pomodoro_logfile()) +if settings.pomodoro_logfile(): + # This works for one file: + timelog = pd.read_csv(settings.pomodoro_logfile()) +else: + # For multiple files: + path = settings.pomodoro_logpath() + all_files = glob.glob(path + "*.csv") -# 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) + li = [] -# timelog = pd.concat(li, axis=0, ignore_index=True) + 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) if debug: imported = copy.deepcopy(timelog)