JSON in Flat File to MySQL DatabaseSo how do you load that JSON
data file into MySQL. Recently I had this question presented to
me and I thought I would share a handy script I use to do such
work. For this example I will use the US Zip (postal) codes from
JSONAR. Download and unzip the file. The data file
is named zips.json and it can not be bread directly into
MySQL using the SOURCE command. It needs to have the information
wrapped in a more palatable fashion.
head zips.json
{ "city" : "AGAWAM", "loc" : [ -72.622739, 42.070206 ], "pop" : 15338, "state" : "MA", "_id" : "01001" }
{ "city" : "CUSHMAN", "loc" : [ -72.51564999999999, 42.377017 ], "pop" : 36963, "state" : "MA", "_id" : "01002" }
{ "city" : "BARRE", "loc" : [ -72.10835400000001, 42.409698 ], "pop" : 4546, "state" : "MA", "_id" : "01005" }
{ "city" : "BELCHERTOWN", "loc" : [ -72.41095300000001, …
[Read more]