MySQL Forums
Forum List  »  MySQL Workbench

Import CSV file with JSON object
Posted by: Sravani Yajamanam
Date: February 18, 2018 01:22AM


I would like to import a CSV file with a JSON object. This is an example of how my CSV file looks like:

pizzaID, type
1, {"cheese": 0, "pepperoni": 0, "hawaiian": 1}
2, {"cheese": 0, "pepperoni": 1, "hawaiian": 0}
3, {"cheese": 1, "pepperoni": 0, "hawaiian": 0}

When I try importing this CSV file into MySQL workbench, this is the error I get:

mysql> load data local infile 'testJSON.csv' into table testJSON fields terminated by ',' enclosed by '"' lines terminated by '\n' (pizzaID, type);
ERROR 3140 (22032): Invalid JSON text: "Missing a comma or '}' after an object member." at position 12 in value for column 'testJSON.type'.

Any idea on how to resolve this issue? Will I need to change some formatting in my CSV file?

Any help is much appreciated! Thanks!

Options: ReplyQuote

Written By
Import CSV file with JSON object
February 18, 2018 01:22AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.