2017-06-07 3 views
0

Ich habe eine geschachtelte JSON. Ich möchte es in Pandas lesen, um es zu erforschen, aber ich habe Fehler. Wann ich die read_json Methode benutzen sollte, habe ich: "Trailing data". Es ist gültiges JSON. Wie man es in pd liest? (Versucht anders, hat aber nicht funktioniert). Es sieht wie folgt aus:Kann JSON in Pandas nicht lesen

{ 
"contributors": null, 
"coordinates": null, 
"created_at": "Fri May 26 08:54:00 +0000 2017", 
"entities": { 
    "hashtags": [], 
    "media": [ 
     { 
      "display_url": "pic.twitter.com/Pm28ORTePl", 
      "expanded_url": "", 
      "id": 868027417121751040, 
      "id_str": "868027417121751040", 
      "indices": [ 
       94, 
       117 
      ], 
      "media_url": "", 
      "sizes": { 
       "large": { 
        "h": 404, 
        "resize": "fit", 
        "w": 773 
       }, 
       "medium": { 
        "h": 404, 
        "resize": "fit", 
        "w": 773 
       }, 
       "small": { 
        "h": 355, 
        "resize": "fit", 
        "w": 680 
       }, 
       "thumb": { 
        "h": 150, 
        "resize": "crop", 
        "w": 150 
       } 
      }, 
      "type": "photo", 
      "url": "" 
     } 
    ], 
    "symbols": [], 
    "urls": [ 
     { 
      "display_url": "", 
      "expanded_url": "", 
      "indices": [ 
       70, 
       93 
      ], 
      "url": "" 
     } 
    ], 
    "user_mentions": [] 
}, 
"extended_entities": { 
    "media": [ 
     { 
      "display_url": "pic.twitter.com/Pm28ORTePl", 
      "expanded_url": "1", 
      "id": 868027417121751040, 
      "id_str": "868027417121751040", 
      "indices": [ 
       94, 
       117 
      ], 
      "media_url": "", 
      "media_url_https": "", 
      "sizes": { 
       "large": { 
        "h": 404, 
        "resize": "fit", 
        "w": 773 
       }, 
       "medium": { 
        "h": 404, 
        "resize": "fit", 
        "w": 773 
       }, 
       "small": { 
        "h": 355, 
        "resize": "fit", 
        "w": 680 
       }, 
       "thumb": { 
        "h": 150, 
        "resize": "crop", 
        "w": 150 
       } 
      }, 
      "type": "photo", 
      "url": "" 
     } 
    ] 
}, 
"favorite_count": 1, 
"favorited": false, 
"geo": null, 
"id": 868027425757724672, 
"id_str": "868027425757724672", 
"in_reply_to_screen_name": null, 
"in_reply_to_status_id": null, 
"in_reply_to_status_id_str": null, 
"in_reply_to_user_id": null, 
"in_reply_to_user_id_str": null, 
"is_quote_status": false, 
"lang": "ru", 
"place": null, 
"possibly_sensitive": false, 
"retweet_count": 0, 
"retweeted": false, 
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>", 
"text": "\u041f\u0440\u043e\u043f\u0430\u0432\u0448\u0430\u044f \u0432 \u041a\u043e\u043a\u0448\u0435\u0442\u0430\u0443 \u0448\u043a\u043e\u043b\u044c\u043d\u0438\u0446\u0430 \u0436\u0438\u043b\u0430 \u0432 \u0437\u0430\u0431\u0440\u043e\u0448\u0435\u043d\u043d\u043e\u043c \u0434\u043e\u043c\u0435 \u0438 \u0431\u0440\u043e\u0434\u044f\u0436\u043d\u0438\u0447\u0430\u043b\u0430\n", 
"truncated": false, 
"user": { 
    "contributors_enabled": false, 
    "created_at": "Wed May 18 11:59:50 +0000 2011", 
    "default_profile": true, 
    "default_profile_image": false, 
    "description": "\u041a\u0430\u0437\u0430\u0445\u0441\u0442\u0430\u043d\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043f\u043e\u0440\u0442\u0430\u043b", 
    "entities": { 
     "description": { 
      "urls": [] 
     }, 
     "url": { 
      "urls": [ 
       { 
        "display_url": "", 
        "expanded_url": "", 
        "indices": [ 
         0, 
         22 
        ], 
        "url": "" 
       } 
      ] 
     } 
    }, 
    "favourites_count": 87, 
    "follow_request_sent": false, 
    "followers_count": 17989, 
    "following": true, 
    "friends_count": 98, 
    "geo_enabled": true, 
    "has_extended_profile": false, 
    "id": 300811189, 
    "id_str": "300811189", 
    "is_translation_enabled": false, 
    "is_translator": false, 
    "lang": "ru", 
    "listed_count": 86, 
    "location": "\u0410\u043b\u043c\u0430\u0442\u044b", 
    "name": "", 
    "notifications": false, 
    "profile_background_color": "C0DEED", 
    "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", 
    "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", 
    "profile_background_tile": false, 
    "profile_banner_url": "https://pbs.twimg.com/profile_banners/300811189/1489117916", 
    "profile_image_url": "http://pbs.twimg.com/profile_images/840047424882298881/NxZSyfhM_normal.jpg", 
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/840047424882298881/NxZSyfhM_normal.jpg", 
    "profile_link_color": "1DA1F2", 
    "profile_sidebar_border_color": "C0DEED", 
    "profile_sidebar_fill_color": "DDEEF6", 
    "profile_text_color": "333333", 
    "profile_use_background_image": true, 
    "protected": false, 
    "screen_name": "", 
    "statuses_count": 53011, 
    "time_zone": "Quito", 
    "translator_type": "none", 
    "url": "", 
    "utc_offset": -18000, 
    "verified": false 
} 

}

Antwort

0

Sorry, aber Ihr JSON ist eigentlich nicht gültig, obwohl Sie sagen es ist.

Diese Zeile: "media_url": "": "",

Sollte wahrscheinlich sein: "media_url": "",

An diesem Punkt, wenn ich die letzte Klammer } hinzugefügt, die außerhalb des Codeblocks, validiert als richtig gebildet JSON war.