Skip to content

Commit a9f7c86

Browse files
authored
Update get.py
1 parent 69b99f5 commit a9f7c86

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

braininventory/get.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
def get_jsonFile(df):
77
"""
88
Input: dataframe
9-
Expected Output: link that opens the jsonFile that was located in the randomly chosen row
10-
Current Output: broken link resulting in Error 404 on the webpage
9+
Output:open the jsonFile that was located in datasets Brain Image Library dataframe
1110
"""
12-
isNotZero = df[df["score"] != 0.0] #only select rows != 0
13-
randomRow = isNotZero.iloc[random.randint(0, len(isNotZero))] #select a random row of random index bt 0 and len of isNotZero
14-
jsonFile = randomRow.json_file.replace("/bil/data", "https://brainimagelibrary.org", 1) #replace (/bil/data) from the json_file
15-
print(jsonFile) #ERROR 404
11+
isNotZero = df[df["score"] != 0.0] #only have files with the correct data
12+
randomRow = isNotZero.iloc[random.randint(0, len(isNotZero))] #select a random row of random index
13+
jsonFileLink = randomRow.json_file.replace("/bil/data", "https://download.brainimagelibrary.org", 1) #create the link
14+
result = requests.get(jsonFileLink)
1615

16+
return result.json()
17+
1718
def today():
1819
"""
1920
Get today's snapshot of Brain Image Library.

0 commit comments

Comments
 (0)