Skip to content

Commit

Permalink
Handle formatting issues of Decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyyid committed Sep 7, 2021
1 parent a8f5188 commit 496a945
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup

setup(name='target-csv',
version='0.3.4',
version='0.3.5',
description='Singer.io target for writing CSV files',
author='Stitch',
url='https://singer.io',
Expand All @@ -12,6 +12,7 @@
install_requires=[
'jsonschema==2.6.0',
'singer-python==5.12.1',
'simplejson==3.11.1'
],
entry_points='''
[console_scripts]
Expand Down
5 changes: 4 additions & 1 deletion target_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import sys
import json
import simplejson
import csv
import threading
import http.client
Expand Down Expand Up @@ -91,7 +92,9 @@ def persist_messages(delimiter, quotechar, messages, destination_path, fixed_hea
if file_is_empty:
writer.writeheader()

writer.writerow(flattened_record)
# We use simplejson to re-serialize the data to avoid formatting issues in the CSV
r = simplejson.dumps(flattened_record)
writer.writerow(simplejson.loads(r))

state = None
elif message_type == 'STATE':
Expand Down

0 comments on commit 496a945

Please sign in to comment.