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

UTF-8 characters from marketo are improperly decoded #74 #75

Open
wants to merge 1 commit 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
5 changes: 3 additions & 2 deletions tap_marketo/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,17 @@ def wait_for_export(client, state, stream, export_id):
# This function has an issue with UTF-8 data most likely caused by decode_unicode=True
# See https://github.com/singer-io/tap-marketo/pull/51/files
def stream_rows(client, stream_type, export_id):
with tempfile.NamedTemporaryFile(mode="w+", encoding="utf8") as csv_file:
with tempfile.NamedTemporaryFile(mode="w+", encoding="utf8", delete=False) as csv_file:
singer.log_info("Download starting.")
resp = client.stream_export(stream_type, export_id)
resp.encoding = 'utf-8'
for chunk in resp.iter_content(chunk_size=CHUNK_SIZE_BYTES, decode_unicode=True):
if chunk:
# Replace CR
chunk = chunk.replace('\r', '')
csv_file.write(chunk)

singer.log_info("Download completed. Begin streaming rows.")
singer.log_info("Download completed. Begin streaming rows to file: " + csv_file.name)
csv_file.seek(0)

reader = csv.reader((line.replace('\0', '') for line in csv_file), delimiter=',', quotechar='"')
Expand Down