Editing Community Data Science Course (Spring 2023)/Week 5 coding challenges
From CommunityData
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 48: | Line 48: | ||
[*] You will probably not be shocked to hear that I collected this data from an API! I've included a Jupyter Notebook with the code to grab that data from [https://petscan.wmflabs.org/ the PetScan API] [https://github.com/kayleachampion/spr23_CDSW/blob/main/curriculum/week5/get_washington_alternative_rock_bands_list-20230425.ipynb in the form of this Github notebook]. | [*] You will probably not be shocked to hear that I collected this data from an API! I've included a Jupyter Notebook with the code to grab that data from [https://petscan.wmflabs.org/ the PetScan API] [https://github.com/kayleachampion/spr23_CDSW/blob/main/curriculum/week5/get_washington_alternative_rock_bands_list-20230425.ipynb in the form of this Github notebook]. | ||
If you just want to read it in the file, remember it's just a JSONL file so you can modify the code from the lecture and it should work | If you just want to read it in the file, remember it's just a JSONL file so you can modify the code from the lecture and it should work. Here's code that loads it in and prints out each line: | ||
<syntaxhighlight lang="python"> | |||
with open("list_of_washington_alternative_rocks_bands_wikipedia-2023-04-25.jsonl", 'r') as input_file: | |||
for line in input_file.readlines(): | |||
line_dict = json.loads(line) | |||
print(line_dict['page_title']) | |||
</syntaxhighlight> |