8
8
import compiler_admin .services .files as files
9
9
10
10
# input CSV columns needed for conversion
11
- INPUT_COLUMNS = ["Date" , "Client" , "Project" , "Notes" , "Hours" , "First name" , "Last name" ]
11
+ HARVEST_COLUMNS = ["Date" , "Client" , "Project" , "Notes" , "Hours" , "First name" , "Last name" ]
12
12
13
13
# default output CSV columns
14
- OUTPUT_COLUMNS = ["Email" , "Start date" , "Start time" , "Duration" , "Project" , "Task" , "Client" , "Billable" , "Description" ]
14
+ TOGGL_COLUMNS = ["Email" , "Start date" , "Start time" , "Duration" , "Project" , "Task" , "Client" , "Billable" , "Description" ]
15
15
16
16
17
17
def _calc_start_time (group : pd .DataFrame ):
@@ -33,8 +33,9 @@ def _toggl_client_name():
33
33
def convert_to_toggl (
34
34
source_path : str | TextIO = sys .stdin ,
35
35
output_path : str | TextIO = sys .stdout ,
36
+ output_cols : list [str ] = TOGGL_COLUMNS ,
36
37
client_name : str = None ,
37
- output_cols : list [ str ] = OUTPUT_COLUMNS ,
38
+ ** kwargs ,
38
39
):
39
40
"""Convert Harvest formatted entries in source_path to equivalent Toggl formatted entries.
40
41
@@ -52,7 +53,7 @@ def convert_to_toggl(
52
53
client_name = _toggl_client_name ()
53
54
54
55
# read CSV file, parsing dates
55
- source = files .read_csv (source_path , usecols = INPUT_COLUMNS , parse_dates = ["Date" ], cache_dates = True )
56
+ source = files .read_csv (source_path , usecols = HARVEST_COLUMNS , parse_dates = ["Date" ], cache_dates = True )
56
57
57
58
# rename columns that can be imported as-is
58
59
source .rename (columns = {"Project" : "Task" , "Notes" : "Description" , "Date" : "Start date" }, inplace = True )
@@ -89,3 +90,6 @@ def convert_to_toggl(
89
90
output_data .sort_values (["Start date" , "Start time" , "Email" ], inplace = True )
90
91
91
92
files .write_csv (output_path , output_data , output_cols )
93
+
94
+
95
+ CONVERTERS = {"toggl" : convert_to_toggl }
0 commit comments