From 6d2902807908e47d67f2fb69eda6458c2622880c Mon Sep 17 00:00:00 2001 From: Andy Lu Date: Mon, 8 Feb 2021 22:20:48 +0000 Subject: Add transform function to drop date of time fields --- tap_google_sheets/sync.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tap_google_sheets/sync.py b/tap_google_sheets/sync.py index 26c2d19..986c6ca 100644 --- a/tap_google_sheets/sync.py +++ b/tap_google_sheets/sync.py @@ -64,6 +64,15 @@ def write_bookmark(state, stream, value): singer.write_state(state) +def drop_date_on_time(schema, record): + for field, field_schema in schema['properties'].items(): + if field_schema.get('format') == 'time': + # `time` fields come back from Google like `X days, H:M:S` + old_time = record[field] + new_time = old_time.split(',')[1].strip() + record[field] = new_time + return record + # Transform/validate batch of records w/ schema and sent to target def process_records(catalog, stream_name, @@ -78,8 +87,9 @@ def process_records(catalog, # Transform record for Singer.io with Transformer() as transformer: try: + edited_record = drop_date_on_time(schema, record) transformed_record = transformer.transform( - record, + edited_record, schema, stream_metadata) except Exception as err: -- cgit v1.2.3