Skip to content

Commit 42bca7a

Browse files
authored
Merge pull request #218 from OpenUpSA/pandas-fix
Refactor TSV to JSON conversion to replace NaN with None for valid Po…
2 parents 85a17ed + cf492e4 commit 42bca7a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

helpers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,9 @@ def tsv_to_json_pandas(tsv_string, project_id):
629629
# Ensure string type, replace NaN with empty string
630630
df[column] = df[column].fillna('')
631631

632-
# IMPROVEMENT 7: Convert to list of dicts efficiently
633-
# pandas to_dict is much faster than manual iteration
632+
# Replace all NaN with None so JSON is valid for Postgres
633+
df = df.where(pd.notnull(df), None)
634634
json_list = df.to_dict('records')
635-
636635
return json_list
637636

638637

0 commit comments

Comments
 (0)