From 367b69da3d617bb18fd2a1afd56aee5a52240572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Wed, 28 Apr 2021 00:14:48 -0400 Subject: [PATCH] Allow multiple entries to be put into one by splitting with semicolon --- pomodoro_to_harvest.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pomodoro_to_harvest.py b/pomodoro_to_harvest.py index 6d895be..af34cf3 100644 --- a/pomodoro_to_harvest.py +++ b/pomodoro_to_harvest.py @@ -13,6 +13,16 @@ timelog = pd.read_csv("timelog-titled.csv") timelog = timelog.dropna() timelog = timelog.reset_index(drop=True) +# For debugging, keep original description around. +timelog["orig_desc"] = timelog["description"] + +# Clean up description before we go to work on it. +timelog['description'] = timelog['description'].str.strip() + +timelog["description"] = list(timelog["description"].str.split(";")) + +timelog = timelog.explode("description").reset_index() + timelog["started"] = pd.to_datetime(timelog["started"]).dt.tz_convert("US/Eastern") timelog["recorded"] = pd.to_datetime(timelog["recorded"]).dt.tz_convert("US/Eastern") timelog["time"] = 30 @@ -22,12 +32,6 @@ timelog["time"] = 30 timelog["date"] = timelog["started"].dt.tz_convert("US/Pacific").dt.date timelog["day_of_week"] = pd.to_datetime(timelog["date"]).dt.day_name() -# For debugging, keep original description around. -timelog["orig_desc"] = timelog["description"] - -# Clean up description before we go to work on it. -timelog['description'] = timelog['description'].str.strip() - # If a project has been specified (task prefixed with a colon), then put the # project in its own column. timelog['project'] = (np.where(timelog['description'].str.contains(': '), timelog['description'].str.split(': ', 1).str[0], None))