singer-io / tap-marketo

GNU Affero General Public License v3.0
9 stars 17 forks source link

UTF-8 characters from marketo are improperly decoded #74

Open abrittis opened 3 years ago

abrittis commented 3 years ago

Steps to reproduce

Expected Results

Actual Results

Proposed Solution

tap-marketo.sync.py

def stream_rows(client, stream_type, export_id):
    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)
        # Force response encoding to 'utf-8' since Marketo doesn't set this properly
        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)