Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transform function to drop date of time fields #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion tap_google_sheets/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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' and 'days,' in record[field]:
# `time` fields can 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,
Expand All @@ -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:
Expand Down