title: python json error: ValueError: Expecting value: line 1 column 1 (char 0)
body: <p>I'm from Korea, so probably you don't understand clearly.</p>
  
  <p>I have a issue about loading json file via python.</p>
  
  <pre><code>with open("D:/twitter/salathe-us-twitter/20110312/SB_DATA_SB/tweets.txt.2011-03-12_01", encoding='UTF8') as f:
  for line in f:
      temp = line.partition('|')
      date.append(temp[0])  # date
      tweets_data.append(temp[2])
  </code></pre>
  
  <p>Here's my python code.
  I seperate the line because there're some errors.</p>
  
  <p>The temp looks like:</p>
  
  <pre><code>('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 &amp; 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\\" &amp;lt;&amp;lt;&amp;lt; 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', '', '')
  </code></pre>
  
  <p>You can see ('\n', '', ''). That's why I partition them.</p>
  
  <p>So I tried to put temp[2] to parameter of json.loads().</p>
  
  <p>But it says</p>
  
  <pre><code>C:\Python34\python.exe D:/Twitter_project/TEST.py
  Traceback (most recent call last):
  File "D:/Twitter_project/TEST.py", line 5, in &lt;module&gt;
  a = json.loads(temp[2])
  File "C:\Python34\lib\json\__init__.py", line 318, in loads
  return _default_decoder.decode(s)
  File "C:\Python34\lib\json\decoder.py", line 343, in decode
  obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python34\lib\json\decoder.py", line 361, in raw_decode
  raise ValueError(errmsg("Expecting value", s, err.value)) from None
  ValueError: Expecting value: line 1 column 1 (char 0)
  </code></pre>
  
  <p>What's the problem of my code?
  The data isn't json format?</p>
  
  <p>So now, I'm just using try, exception to read the data for temporary.</p>
  
  <p>It worked. But I want to know why it happen and how to fix it.</p>
  
  <p>Here's my try except code:</p>
  
  <pre><code>import json
  date = []
  tweets_data = []
  with open("D:/twitter/salathe-us-       twitter/20110302/SB_DATA_SB/tweets.txt.2011-03-02_14-05", encoding='UTF8') as f:
  for i,line in enumerate(f):
      try:
          temp = line.partition('|')
          date.append(temp[0])
          tweet = json.loads(temp[2])
          tweets_data.append(tweet)
      except:
          continue
  </code></pre>