Closed JJSell1 closed 11 months ago
There's no easy way to do it with the current functionality, but if you'd like to dig through the data, you can find it here: https://nflscorigami.com/copydb
It wasn't really hard to do. Your data is in a nested array. I just had to clean that up. Here is a copy of my code if you want to see it. Just saves it now to a csv.
fetch('https://nflscorigami.com/data') .then( response => { if (response.status !== 200) { console.log('Looks like there was a problem. Status Code: ' + response.status); return; }
// Examine the text in the response
response.json().then(function (data) {
//console.log(JSON.stringify(data));
//console.log('data.lemght: ' + data.matrix.length)
var masterArray = []
data.matrix.forEach(function (ptsLose) {
//console.log('items at index ' + data.matrix.indexOf(ptsLose) +
' - ptsLose.length ' + ptsLose.length) ptsLose.forEach(function (item) { if(item.count != 0){ masterArray.push(item) } }) //console.log('current masterarray.length after a batch of ptsLose items: ' + masterArray.length) })
//console.log(masterArray.length)
var allWinnerNames = masterArray.map(function (item) {
return item.first_team_win
})
var allLoserNames = masterArray.map(function (item) {
return item.first_team_lose
})
var allNames = allWinnerNames.concat(allLoserNames)
var allUniqueNames = allNames.filter(filterUniques)
//console.log(allUniqueNames.length)
allUniqueNames.sort()
let exportData = []
exportData.push("Team,Total,Home Wins,Home Loses,Away Wins,Away
Loses")
allUniqueNames.map(function(teamToLookUp){
let total = masterArray.filter(function(item){return (item.
first_team_win == teamToLookUp || item.first_team_lose == teamToLookUp)}). length let homeWins = masterArray.filter(function(item){return (item. first_team_home == teamToLookUp && item.first_team_win == teamToLookUp)}). length let homeLoses = masterArray.filter(function(item){return (item. first_team_home == teamToLookUp && item.first_team_lose == teamToLookUp)}). length let awayWins = masterArray.filter(function(item){return (item. first_team_away == teamToLookUp && item.first_team_win == teamToLookUp)}). length let awayLoses = masterArray.filter(function(item){return (item. first_team_away == teamToLookUp && item.first_team_lose == teamToLookUp)}). length exportData.push(teamToLookUp + ',' + total + ',' + homeWins + ','
homeLoses + ',' + awayWins + ',' + awayLoses) }) var csv = exportData.map(function(d){ return JSON.stringify(d) }).join(('\n')) console.log(csv)
const fs = require('fs')
fs.writeFile('betterScoriGami.csv', csv, (err) => {
if (err) throw err;
});
}); }) .catch(err => console.log('Fetch Error :-S', err));
function filterUniques(item, itemIndex, srcArray) { return srcArray.indexOf(item) === itemIndex }
On Mon, Dec 4, 2023 at 2:47 PM Merry3750 @.***> wrote:
There's no easy way to do it with the current functionality, but if you'd like to dig through the data, you can find it here: https://nflscorigami.com/data
— Reply to this email directly, view it on GitHub https://github.com/Merry3750/scorigami/issues/58#issuecomment-1839363946, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ2DIN53VXYBYQVBBOSXMBLYHYSDXAVCNFSM6AAAAABAGHRTYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZZGM3DGOJUGY . You are receiving this because you authored the thread.Message ID: @.***>
But any way to get a total by team that has made a scorigami?