title: Load JSON DATA From GITHUB IN PYTHON AND STREMLIT
body: <p>Hi to all and thanks in advance for your help,</p>
  <p>I´ve developing with streamlit and Python and now I would like to deploy all the thinks in Heroku.</p>
  <p>It´s my first time deploying an app in heroku. I <strong>want to load json files form github</strong> becouse I would like to have the app weekly updated with the statsbomb data.</p>
  <p><strong>Until now I have been loading the json files from my computer,</strong> please find attached the code:</p>
  <pre><code>import streamlit as st
  import pandas as pd
  import json
  import os
  from pandas import json_normalize
  from flatten_json import flatten
  
  import matplotlib.pyplot as plt
  from matplotlib.patches import Arc
  import numpy as np
  from PIL import Image
  import urllib, json
  
  ### NAME OF THE APP ###
  x = st.sidebar.header(' Analytics')  #  this is a widget
  
  ### SEASON SELECTOR ###
  file_to_charge2 = st.sidebar.selectbox('temporada',('Temporada 2018-2019','Temporada 2017-2018','Temporada 2016-2017'))
  
  if file_to_charge2 == 'Temporada 2018-2019':
      file_to_charge = '4.json'
  elif file_to_charge2 == 'Temporada 2017-2018':
      file_to_charge2 = '1.json'
  elif file_to_charge2== 'Temporada 2016-2017':
      file_to_charge = '2.json'
  
  
  ### MATCH SELECTOR ###
  
  home_team = st.sidebar.selectbox('Equipo juega en casa:',('Athletic Bilbao', 'Atlético Madrid', 'Barcelona', 'Celta Vigo', 'Deportivo Alavés', 'Deportivo La Coruna', 'Eibar', 'Espanyol', 'Getafe', 'Girona', 'Granada', 'Las Palmas', 'Leganés', 'Levante', 'Málaga', 'Osasuna', 'Rayo Vallecano', 'Real Betis', 'Real Madrid', 'Real Sociedad', 'Real Valladolid', 'Sevilla', 'Sporting Gijón', 'Valencia', 'Villarreal'))
  away_team = st.sidebar.selectbox('Equipo fuera de casa:',('Athletic Bilbao', 'Atlético Madrid', 'Barcelona', 'Celta Vigo', 'Deportivo Alavés', 'Deportivo La Coruna', 'Eibar', 'Espanyol', 'Getafe', 'Girona', 'Granada', 'Las Palmas', 'Leganés', 'Levante', 'Málaga', 'Osasuna', 'Rayo Vallecano', 'Real Betis', 'Real Madrid', 'Real Sociedad', 'Real Valladolid', 'Sevilla', 'Sporting Gijón', 'Valencia', 'Villarreal'))
  #json_normalize(my_data3, sep='_').assign(match_id=file_name[:-5])
  
  
  
  ###LOAD THE JSON FILE FROM COMPUTER### 
  
  st.title('&gt; Datos por temporada:')
  dfpartidos = json.load(open(os.path.expanduser('~/Desktop/DATOS/open-data-master/data/matches/11/' + file_to_charge), 'r', encoding='utf-8'))
  
  
  
  ### DATAFRAME OF THE SEASON ###
  FIELDS = ['match_id','match_week',&quot;home_team.home_team_name&quot;,'away_team.away_team_name','home_score','away_score','referee.name']
  dfdef = pd.json_normalize(dfpartidos)
  p = dfdef[FIELDS]
  
  ### DATAFRAME OF THE TEAMS ###
  l = p.loc[p['home_team.home_team_name'] == home_team, :]
  l = l.loc[l['away_team.away_team_name'] == away_team, :]
  
  
  
  
  #TABLE WITH DATA OF THE SELECTED SEASON:
  st.subheader('Datos de la  {} :'.format(file_to_charge2))
  st.write(p)
  
  #TABLE WITH DATA OF THE SELECETED TEAMS
  
  st.write('Home Team:',home_team,'VS','Away Team:',away_team)
  
  st.write(l)
  </code></pre>
  <p>This code works well and it's ready to analayze amazing data. But <strong>If I want to have an updated app. And that is the reason why I need to launch the json files form github</strong>. I have done some unsuccesfull tests but I have some issues. Please find attached the code and the error.</p>
  <pre><code>import streamlit as st
  import pandas as pd
  import json
  import os
  from pandas import json_normalize
  from flatten_json import flatten
  
  import matplotlib.pyplot as plt
  from matplotlib.patches import Arc
  import numpy as np
  from PIL import Image
  import urllib, json
  import plotly.express as px
  import altair as atl
  import re, json, requests
  
  x = st.sidebar.header(' Analytics')  #  this is a widget
  
  ####
  file_to_charge2 = st.sidebar.selectbox('temporada',
                                         ('Temporada 2018-2019', 'Temporada 2017-2018', 'Temporada 2016-2017'))
  
  if file_to_charge2 == 'Temporada 2018-2019':
      file_to_charge = '4.json'
  elif file_to_charge2 == 'Temporada 2017-2018':
      file_to_charge2 = '1.json'
  elif file_to_charge2 == 'Temporada 2016-2017':
      file_to_charge = '2.json'
  
  
  ### busqueda de partidos ###
  
  home_team = st.sidebar.selectbox('Equipo juega en casa:', (
  'Athletic Bilbao', 'Atlético Madrid', 'Barcelona', 'Celta Vigo', 'Deportivo Alavés', 'Deportivo La Coruna', 'Eibar',
  'Espanyol', 'Getafe', 'Girona', 'Granada', 'Las Palmas', 'Leganés', 'Levante', 'Málaga', 'Osasuna', 'Rayo Vallecano',
  'Real Betis', 'Real Madrid', 'Real Sociedad', 'Real Valladolid', 'Sevilla', 'Sporting Gijón', 'Valencia', 'Villarreal'))
  away_team = st.sidebar.selectbox('Equipo fuera de casa:', (
  'Athletic Bilbao', 'Atlético Madrid', 'Barcelona', 'Celta Vigo', 'Deportivo Alavés', 'Deportivo La Coruna', 'Eibar',
  'Espanyol', 'Getafe', 'Girona', 'Granada', 'Las Palmas', 'Leganés', 'Levante', 'Málaga', 'Osasuna', 'Rayo Vallecano',
  'Real Betis', 'Real Madrid', 'Real Sociedad', 'Real Valladolid', 'Sevilla', 'Sporting Gijón', 'Valencia', 'Villarreal'))
  # json_normalize(my_data3, sep='_').assign(match_id=file_name[:-5])
  
  
  
  
  ### TRYING TO LOAD DATA FROM GITHUB // THE PROBLEM ###
  url = 'https://raw.github.com/statsbomb/open-data/matches/11/' + file_to_charge
  resp = requests.get(url)
  st.title('&gt; Datos por temporada:')
  dfpartidos = json.loads(resp.text)
  
  
  
  ### DATAFRAME OF THE SEASON ###
  FIELDS = ['match_id', 'match_week', &quot;home_team.home_team_name&quot;, 'away_team.away_team_name', 'home_score', 'away_score',
            'referee.name']
  dfdef = pd.json_normalize(dfpartidos)
  p = dfdef[FIELDS]
  
  # DATAFRAME SEGÚN EQUIPOS FILTRADOS
  l = p.loc[p['home_team.home_team_name'] == home_team, :]
  l = l.loc[l['away_team.away_team_name'] == away_team, :]
  
  # TABLE WITH DATA OF THE SELECTED SEASON:
  st.subheader('Datos de la  {} :'.format(file_to_charge2))
  st.write(p)
  
  # TABLE WITH DATA OF THE SELECETED TEAMS
  
  st.write('Home Team:', home_team, 'VS', 'Away Team:', away_team)
  
  st.write(l)
  </code></pre>
  <p><strong>And the error loading json date from github.</strong></p>
  <pre><code>JSONDecodeError: Extra data: line 1 column 4 (char 3)
  Traceback:
  File &quot;/Users/DOMIN2662/Desktop/streamlit/venv/lib/python3.7/site-packages/streamlit/script_runner.py&quot;, line 324, in _run_script
      exec(code, module.__dict__)
  File &quot;/Users/DOMIN2662/Desktop/streamlit/duda22.py&quot;, line 50, in &lt;module&gt;
      dfpartidos = json.loads(resp.text)
  File &quot;/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py&quot;, line 348, in loads
      return _default_decoder.decode(s)
  File &quot;/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py&quot;, line 340, in decode
      raise JSONDecodeError(&quot;Extra data&quot;, s, end)
  </code></pre>
  <p>I want to highlight the support of comunity and I hope that in the next future I can help others  developers.</p>