将大型JSON转换为csv

时间:2017-05-16 19:42:26

标签: python json csv

我试图将相当大的JSON文件转换为CSV格式。

'{"latitude":34.700869,"longitude":135.503755,"timezone":"Asia/Tokyo","offset":9,"currently":{"time":1422831600,"summary":"Clear","icon":"clear-day","precipType":"rain","temperature":3.51,"apparentTemperature":1.37,"dewPoint":-2.53,"humidity":0.65,"windSpeed":2.24,"windBearing":294,"visibility":11.76,"pressure":1028.66},"hourly":{"summary":"Clear throughout the day.","icon":"clear-day","data":[{"time":1422802800,"summary":"Clear","icon":"clear-night","precipType":"rain","temperature":2.94,"apparentTemperature":1.07,"dewPoint":-2.09,"humidity":0.7,"windSpeed":1.91,"windBearing":295,"visibility":14.52,"pressure":1029.11},{"time":1422806400,"summary":"Clear","icon":"clear-night","precipType":"rain","temperature":2.88,"apparentTemperature":0.65,"dewPoint":-2.12,"humidity":0.7,"windSpeed":2.23,"windBearing":292,"visibility":14.52,"pressure":1028.7},{"time":1422810000,"summary":"Clear","icon":"clear-night","precipType":"rain","temperature":2.88,"apparentTemperature":0.78,"dewPoint":-2.17,"humidity":0.69,"windSpeed":2.11,"windBearing":270,"visibility":14.16,"pressure":1028.52},{"time":1422813600,"summary":"Partly Cloudy","icon":"partly-cloudy-night","precipType":"rain","temperature":2.84,"apparentTemperature":0.47,"dewPoint":-2.12,"humidity":0.7,"windSpeed":2.36,"windBearing":282,"visibility":15.77,"cloudCover":0.38,"pressure":1028.25},{"time":1422817200,"summary":"Clear","icon":"clear-night","precipType":"rain","temperature":2.84,"apparentTemperature":0.65,"dewPoint":-2.13,"humidity":0.7,"windSpeed":2.19,"windBearing":285,"visibility":14.52,"pressure":1028.16},{"time":1422820800,"summary":"Clear","icon":"clear-night","precipType":"rain","temperature":2.88,"apparentTemperature":0.56,"dewPoint":-1.72,"humidity":0.72,"windSpeed":2.32,"windBearing":301,"visibility":12.41,"pressure":1028.21},{"time":1422824400,"summary":"Mostly Cloudy","icon":"partly-cloudy-night","precipType":"rain","temperature":2.84,"apparentTemperature":0.55,"dewPoint":-1.82,"humidity":0.71,"windSpeed":2.28,"windBearing":295,"visibility":14.95,"cloudCover":0.75,"pressure":1028.25},{"time":1422828000,"summary":"Clear","icon":"clear-night","precipType":"rain","temperature":2.97,"apparentTemperature":0.69,"dewPoint":-2.1,"humidity":0.69,"windSpeed":2.29,"windBearing":304,"visibility":12.41,"pressure":1028.55},{"time":1422831600,"summary":"Clear","icon":"clear-day","precipType":"rain","temperature":3.51,"apparentTemperature":1.37,"dewPoint":-2.53,"humidity":0.65,"windSpeed":2.24,"windBearing":294,"visibility":11.76,"pressure":1028.66},{"time":1422835200,"summary":"Mostly Cloudy","icon":"partly-cloudy-day","precipType":"rain","temperature":4.28,"apparentTemperature":2.64,"dewPoint":-3.14,"humidity":0.58,"windSpeed":1.89,"windBearing":285,"visibility":14.63,"cloudCover":0.74,"pressure":1028.55},{"time":1422838800,"summary":"Clear","icon":"clear-day","precipType":"rain","temperature":4.95,"apparentTemperature":2.61,"dewPoint":-3.67,"humidity":0.54,"windSpeed":2.79,"windBearing":301,"visibility":11.76,"pressure":1028.43},{"time":1422842400,"summary":"Clear","icon":"clear-day","precipType":"rain","temperature":6.13,"apparentTemperature":3.48,"dewPoint":-3.35,"humidity":0.51,"windSpeed":3.6,"windBearing":316,"visibility":11.76,"pressure":1027.97},{"time":1422846000,"summary":"Mostly Cloudy","icon":"partly-cloudy-day","precipType":"rain","temperature":5.99,"apparentTemperature":3.08,"dewPoint":-3.91,"humidity":0.49,"windSpeed":3.99,"windBearing":320,"visibility":14.45,"cloudCover":0.75,"pressure":1027.18},{"time":1422849600,"summary":"Clear","icon":"clear-day","precipType":"rain","temperature":6.01,"apparentTemperature":3.01,"dewPoint":-3.74,"humidity":0.5,"windSpeed":4.17,"windBearing":329,"visibility":11.76,"pressure":1026.79},{"time":1422853200,"summary":"Clear","icon":"clear-day","precipType":"rain","temperature":5.94,"apparentTemperature":3.4,"dewPoint":-3.33,"humidity":0.51,"windSpeed":3.34,"windBearing":343,"visibility":11.76,"pressure":1026.69},{"time":1422856800,"summary":"Overcast","icon":"cloudy","precipType":"rain","temperature":5.78,"apparentTemperature":2.98,"dewPoint":-3.41,"humidity":0.52,"windSpeed":3.72,"windBearing":342,"visibility":14.71,"cloudCover":0.96,"pressure":1026.77},{"time":1422860400,"summary":"Clear","icon":"clear-day","precipType":"rain","temperature":5.74,"apparentTemperature":3.42,"dewPoint":-3.07,"humidity":0.53,"windSpeed":2.97,"windBearing":337,"visibility":11.72,"pressure":1026.87},{"time":1422864000,"summary":"Clear","icon":"clear-day","precipType":"rain","temperature":5.33,"apparentTemperature":2.86,"dewPoint":-2.67,"humidity":0.56,"windSpeed":3.07,"windBearing":329,"visibility":11.76,"pressure":1027.16},{"time":1422867600,"summary":"Mostly Cloudy","icon":"partly-cloudy-night","precipType":"rain","temperature":4.43,"apparentTemperature":1.56,"dewPoint":-1.98,"humidity":0.63,"windSpeed":3.37,"windBearing":323,"visibility":14.45,"cloudCover":0.75,"pressure":1027.26},{"time":1422871200,"summary":"Clear","icon":"clear-night","precipType":"rain","temperature":4.36,"apparentTemperature":1.63,"dewPoint":-1.97,"humidity":0.63,"windSpeed":3.14,"windBearing":315,"visibility":11.76,"pressure":1027.55},{"time":1422874800,"summary":"Clear","icon":"clear-night","precipType":"rain","temperature":4.25,"apparentTemperature":1.71,"dewPoint":-1.68,"humidity":0.65,"windSpeed":2.87,"windBearing":300,"visibility":12.41,"pressure":1027.77},{"time":1422878400,"summary":"Mostly Cloudy","icon":"partly-cloudy-night","precipType":"rain","temperature":4.27,"apparentTemperature":1.95,"dewPoint":-1.74,"humidity":0.65,"windSpeed":2.59,"windBearing":313,"visibility":15.8,"cloudCover":0.76,"pressure":1027.98},{"time":1422882000,"summary":"Clear","icon":"clear-night","precipType":"rain","temperature":4.25,"apparentTemperature":1.78,"dewPoint":-1.73,"humidity":0.65,"windSpeed":2.77,"windBearing":297,"visibility":14.52,"pressure":1028.02},{"time":1422885600,"summary":"Clear","icon":"clear-night","precipType":"rain","temperature":4.24,"apparentTemperature":2.03,"dewPoint":-1.72,"humidity":0.65,"windSpeed":2.46,"windBearing":296,"visibility":14.52,"pressure":1028.12}]},"daily":{"data":[{"time":1422802800,"summary":"Clear throughout the day.","icon":"clear-day","sunriseTime":1422827846,"sunsetTime":1422865697,"moonPhase":0.44,"precipType":"rain","temperatureMin":2.84,"temperatureMinTime":1422824400,"temperatureMax":6.13,"temperatureMaxTime":1422842400,"apparentTemperatureMin":0.47,"apparentTemperatureMinTime":1422813600,"apparentTemperatureMax":3.48,"apparentTemperatureMaxTime":1422842400,"dewPoint":-2.49,"humidity":0.62,"windSpeed":2.62,"windBearing":310,"visibility":13.45,"cloudCover":0.73,"pressure":1027.9}]},"flags":{"sources":["isd"],"isd-stations":["476490-99999","476510-99999","476630-99999","476840-99999","477500-99999","477590-99999","477610-99999","477690-99999","477700-99999","477710-99999","477720-99999","477740-99999","477760-99999","477770-99999","477790-99999","477800-99999"],"units":"si"}}'

这只是文件的一小部分。我发现了多个在线转换器,但它们似乎都没有处理文件> 2MB。

是否有方便的python脚本或其他工具来转换它?

0 个答案:

没有答案