This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv, os | |
from collections import Counter | |
# initialise a list and put header in it. | |
sheet = [["id","title","artist","running time","intro length","total number of elements","formal elements","song elements","movement","repetition","key changes","metric changes","title words count"]] | |
# change the working directory. | |
# given that you have a hieralchy like this. | |
# +- hoge | |
# +- dataset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests, csv | |
from bs4 import BeautifulSoup | |
from time import sleep | |
for year in range(1940,2017): | |
print("start scraping " + str(year) + "'s chart.") | |
# initialize and put header on the main 'chart' list. | |
chart = [["rank", "artist name", "song title"]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this code is inspired by Jon Evans' project. | |
# http://www.jw.pe/blog/post/quantifying-sufjan-stevens-with-the-genius-api-and-nltk/ | |
import requests, json | |
from time import sleep | |
# constant values. | |
BASE_URL = "https://api.genius.com" | |
CLIENT_ACCESS_TOKEN = "<YOUR TOKEN HERE>" | |
ARTIST_NAME = "<ANY ARTIST NAME>" |