Skip to content Skip to sidebar Skip to footer

Python Json Error: ValueError: Expecting Value: Line 1 Column 1 (char 0)

I'm from Korea, so probably you don't understand clearly. I have a issue about loading json file via python. with open('D:/twitter/salathe-us-twitter/20110312/SB_DATA_SB/tweets.txt

Solution 1:

As first i have tried that you have valid JSON format according this validator and you have.

Then i have tried to write same code and the following code works fine for me withnout any exceptions.

import json

temp = ('20110302141002236', '|', '{"user":{"following":null,"profile_background_image_url":"http:\\/\\/a3.twimg.com\\/profile_background_images\\/141128439\\/2010-07-01_15.33.10.jpg","favourites_count":1,"verified":false,"time_zone":"Pacific Time (US & Canada)","profile_text_color":"333333","follow_request_sent":null,"profile_sidebar_fill_color":"DDEEF6","id_str":"173736821","profile_background_tile":false,"followers_count":19,"created_at":"Mon Aug 02 06:37:45 +0000 2010","description":"Attend CWU and just tryna do me.","is_translator":false,"show_all_inline_media":false,"geo_enabled":true,"profile_link_color":"0084B4","location":"Tacoma, WA","listed_count":1,"profile_sidebar_border_color":"C0DEED","protected":false,"profile_image_url":"http:\\/\\/a3.twimg.com\\/profile_images\\/1208687030\\/Twitter_normal.jpg","lang":"en","name":"Quintin Brown","contributors_enabled":false,"statuses_count":340,"notifications":null,"profile_use_background_image":true,"screen_name":"QBrown15","id":173736821,"utc_offset":-28800,"friends_count":48,"profile_background_color":"C0DEED","url":"http:\\/\\/www.facebook.com\\/#!\\/profile.php?id=1195837597"},"in_reply_to_screen_name":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"contributors":null,"coordinates":null,"retweeted":false,"text":"\\"RT @barr253 I love fat asses. #honesttweet\\" <<< Naw, that\'s an #ObviousTweet","in_reply_to_user_id_str":null,"retweet_count":0,"in_reply_to_status_id":null,"id_str":"43025281954480130","source":"web","created_at":"Wed Mar 02 19:10:01 +0000 2011","truncated":false,"entities":{"user_mentions":[{"indices":[4,12],"id_str":"204626247","name":"John Barr","screen_name":"barr253","id":204626247}],"urls":[],"hashtags":[{"indices":[31,43],"text":"honesttweet"},{"indices":[73,86],"text":"ObviousTweet"}]},"geo":null,"place":{"bounding_box":{"type":"Polygon","coordinates":[[[-120.597461,46.966947],[-120.518162,46.966947],[-120.518162,47.029281],[-120.597461,47.029281]]]},"place_type":"city","name":"Ellensburg","country":"United States","attributes":{},"id":"c95cdb2a983262e5","full_name":"Ellensburg, WA","country_code":"US","url":"http:\\/\\/api.twitter.com\\/1\\/geo\\/id\\/c95cdb2a983262e5.json"},"favorited":false,"id":43025281954480130}\n')
('\n', '', '')

a = json.loads(temp[2])

Tested on Python 3.5, 3.3


Post a Comment for "Python Json Error: ValueError: Expecting Value: Line 1 Column 1 (char 0)"