Skip to content

Commit bacda1a

Browse files
authored
fix data types for solidgate (#309)
1 parent 501e053 commit bacda1a

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

ingestr/src/solidgate/__init__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,12 @@
8686
"transaction_datetime_provider": {"data_type": "timestamp"},
8787
"transaction_datetime_utc": {"data_type": "timestamp"},
8888
"accounting_date": {"data_type": "date"},
89-
"amount": {"data_type": "decimal", "precision": 18, "scale": 4},
90-
"amount_in_major_units": {"data_type": "decimal", "precision": 18, "scale": 4},
89+
"amount": {"data_type": "double"},
90+
"amount_in_major_units": {"data_type": "double"},
9191
"currency": {"data_type": "text"},
9292
"currency_minor_units": {"data_type": "bigint"},
93-
"payout_amount": {"data_type": "decimal", "precision": 18, "scale": 4},
94-
"payout_amount_in_major_units": {
95-
"data_type": "decimal",
96-
"precision": 18,
97-
"scale": 4,
98-
},
93+
"payout_amount": {"data_type": "double"},
94+
"payout_amount_in_major_units": {"data_type": "double"},
9995
"payout_currency": {"data_type": "text"},
10096
"payout_currency_minor_units": {"data_type": "bigint"},
10197
"record_type_key": {"data_type": "text"},

ingestr/src/solidgate/helpers.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import base64
2+
import csv
23
import hashlib
34
import hmac
45
import json
@@ -123,11 +124,18 @@ def fetch_financial_entry_data(
123124
except json.JSONDecodeError:
124125
try:
125126
csv_data = get_response.content.decode("utf-8")
126-
df = pd.read_csv(StringIO(csv_data))
127-
df["created_at"] = df["created_at"].apply(
128-
lambda x: pendulum.parse(x)
129-
)
130-
return df
127+
reader = csv.DictReader(StringIO(csv_data))
128+
rows = []
129+
for row in reader:
130+
if row["created_at"]:
131+
row["created_at"] = pendulum.parse(row["created_at"])
132+
else:
133+
row["created_at"] = None
134+
135+
row2 = {k: v for k, v in row.items() if v != ''}
136+
rows.append(row2)
137+
138+
return rows
131139
except Exception as e:
132140
raise Exception(f"Error reading CSV: {e}")
133141
else:

0 commit comments

Comments
 (0)