Reputation: 1893
I have a csv file I'm trying to load to Snowflake that has a column 'custom_fields', everything in this column is a dictionary, but one row had a None key, for example {'Account_ID': None}
which threw the error
Error parsing JSON: {'Account_ID': None}
I have the format set up like below, where I tried also adding 'None' within null_if
@property
def fileformat_opts(self):
return {
'type': 'csv',
'skip_header': 1,
'field_delimiter': ',',
'field_optionally_enclosed_by': '"',
'escape_unenclosed_field': None,
'date_format': 'YYYY-MM-DD',
'record_delimiter': '\n',
'null_if': ('NULL', '', ' ', 'NULL', '//N', 'None'),
'empty_field_as_null': True,
'error_on_column_count_mismatch': False,
'timestamp_format': 'YYYY-MM-DD HH24:MI:SS'
}
Upvotes: 1
Views: 711
Reputation: 11
You need dumps dictionary to json, e.g. in python json.dumps(dict)
, then only can load to Snowflake as object
or variant
Upvotes: 1
Reputation: 10039
I think you are trying to parse this:
{"Account_ID": None}
None is not a valid JSON value. You can check your JSON string using any online validator. For example:
As a solution, you can write null instead of None to your CSV file.
Upvotes: 0