Skip to content

Instantly share code, notes, and snippets.

@loretoparisi
Last active August 16, 2023 17:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loretoparisi/3676d1471e25964c490d4b418f06ed6f to your computer and use it in GitHub Desktop.
Save loretoparisi/3676d1471e25964c490d4b418f06ed6f to your computer and use it in GitHub Desktop.
Sanremo Music Festival Tracks Dataset
script = document.createElement('script');script.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js";document.getElementsByTagName('head')[0].appendChild(script);
function download(name,jsonObject) {
var fileContents = JSON.stringify(jsonObject, null, 2);
var pp = document.createElement('a');
pp.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(fileContents));
pp.setAttribute('download', name+'.json');
pp.click();
}
const title = $('.firstHeading').text().replace(/[aA-zZ]/g,'').trim();
const table = $('.wikitable').length - 1;
const dataset = $($('.wikitable')[table]).find('tr').slice(1).map((index,item) => {
return {
track_year: title,
track_id: index,
track_pos: $($(item).find('td')[0]).text().trim().replace(/[°º]/,''),
artist_name: $($(item).find('td')[1]).text().trim(),
track_name: $($(item).find('td')[2]).text().trim(),
track_writers: $($(item).find('td')[3]).text().trim(),
track_votes: $($(item).find('td')[4]).text().trim()
};
}).toArray()
download(title,dataset)
@loretoparisi
Copy link
Author

loretoparisi commented Jan 20, 2020

1984-2003

script = document.createElement('script');script.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js";document.getElementsByTagName('head')[0].appendChild(script);
function download(name,jsonObject) {
    var fileContents = JSON.stringify(jsonObject, null, 2);
    var pp = document.createElement('a');
    pp.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(fileContents));
    pp.setAttribute('download', name+'.json');
    pp.click();
}
const title = $('.firstHeading').text().replace(/[aA-zZ]/g,'').trim();
const dataset = (table) => $($('.wikitable')[table]).find('tr').slice(1).map((index,item) => {
    return {
        track_year: title,
        track_id: index,
        track_pos: $($(item).find('td')[0]).text().trim().replace(/[°º]/,''),
        artist_name: $($(item).find('td')[1]).text().trim(),
        track_name: $($(item).find('td')[2]).text().trim(),
        track_writers: $($(item).find('td')[3]).text().trim(),
        track_votes: $($(item).find('td')[4]).text().trim()
    };
}).toArray()
download(title+"_big",dataset(2))
download(title+"_new",dataset(3))

@loretoparisi
Copy link
Author

loretoparisi commented Jan 20, 2020

@DavideTalevi98
Copy link

Please give me the full dataset in .csv, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment