fix json decode error
Browse files
nba_tracking_data_15_16.py
CHANGED
@@ -17,6 +17,7 @@ import csv
|
|
17 |
import json
|
18 |
import os
|
19 |
import py7zr
|
|
|
20 |
|
21 |
import datasets
|
22 |
import requests
|
@@ -44,8 +45,12 @@ _URL = "https://github.com/linouk23/NBA-Player-Movements/raw/master/data/2016.NB
|
|
44 |
_PBP_URL = "https://github.com/sumitrodatta/nba-alt-awards/raw/main/Historical/PBP%20Data/2015-16_pbp.csv"
|
45 |
|
46 |
res = requests.get(_URL)
|
|
|
47 |
|
48 |
-
|
|
|
|
|
|
|
49 |
|
50 |
def home_away_event_conversion(number):
|
51 |
if pd.isna(number.item()):
|
|
|
17 |
import json
|
18 |
import os
|
19 |
import py7zr
|
20 |
+
import re
|
21 |
|
22 |
import datasets
|
23 |
import requests
|
|
|
45 |
_PBP_URL = "https://github.com/sumitrodatta/nba-alt-awards/raw/main/Historical/PBP%20Data/2015-16_pbp.csv"
|
46 |
|
47 |
res = requests.get(_URL)
|
48 |
+
text = res.text
|
49 |
|
50 |
+
json_pattern = r'{"items":*\[.*?\]'
|
51 |
+
json_match = re.findall(json_pattern, text, re.DOTALL)
|
52 |
+
|
53 |
+
ITEMS = json.loads(json_matches[0]+"}")['items']
|
54 |
|
55 |
def home_away_event_conversion(number):
|
56 |
if pd.isna(number.item()):
|