Skip to content

Commit

Permalink
FIX : check if start_date is date type
Browse files Browse the repository at this point in the history
  • Loading branch information
bbaltagi-dtsl committed Aug 30, 2022
1 parent e901989 commit 21a5cd0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tap_qualtrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import zipfile
import requests
from datetime import datetime, timedelta
from dateutil.parser import parse

import singer
from singer import utils, metadata
Expand Down Expand Up @@ -37,6 +38,19 @@
}


def is_date(string, fuzzy=False):
"""
Return whether the string can be interpreted as a date.
:param string: str, string to check for date
:param fuzzy: bool, ignore unknown tokens in string if True
"""
try:
parse(string, fuzzy=fuzzy)
return True

except ValueError:
return False

def get_abs_path(path):
return os.path.join(os.path.dirname(os.path.realpath(__file__)), path)

Expand Down Expand Up @@ -391,7 +405,7 @@ def sync_survey_responses(config, state, stream):

singer.write_records(stream.tap_stream_id, [transformed_data])
counter.increment()
if bookmark_column:
if bookmark_column and is_date(converted_data[bookmark_column]):
local_bookmark = max([local_bookmark, date_format(converted_data[bookmark_column])])
if end_date.split("T")[0] == datetime.today().strftime('%Y-%m-%d'):
break
Expand Down

0 comments on commit 21a5cd0

Please sign in to comment.