Code Monkey home page Code Monkey logo

mega-regression's Introduction

Mega Regression

Importando os Dados

Copie o script abaixo e cole no console da página Resultados a Importar, em seguida clique enter e autorize os downloads.

Os arquivos baixados devem ser introduzidos no diretório data na raiz da aplicação.

extract-data.js

var labels = {},  data = [], key = 0
var table = document.querySelectorAll("body>table>tbody")
var header = table[0]
var body = table[1]


header.childNodes[0].childNodes.forEach((node) => {
    if (node.nodeName === "TH") {
        let key = node.childNodes[1].childNodes[1].innerHTML
                .trim()
                .toLowerCase()
                .replaceAll(" ", "_")
                .replaceAll("ã", "a")
                .replaceAll("ç", "c")

        labels[key] = node.childNodes[1].childNodes[1].innerHTML.trim()
    }
})

let keys = Object.keys(labels)
body.childNodes.forEach((node) => {
    if (node.nodeName == "TR" && node.hasChildNodes()) {
        let item = {}
        node.childNodes.forEach((tdNode) => {
            if(!tdNode.hasChildNodes() && tdNode.nodeName == "TD") {
                item[keys[key]] = tdNode.innerHTML.trim()
                key++
            }

            if ((tdNode.hasChildNodes() && tdNode.nodeName == "TD") && tdNode.childNodes.length === 1) {
                item[keys[key]] = tdNode.childNodes[0].data.trim()
                key++
            }
        })

        if (Object.keys(item).length > 0) data.push(item)
        key = 0
    }
})

function download(content, fileName, contentType) {
    var link = document.createElement("a")
    link.href = URL.createObjectURL(new Blob([content], {type: contentType}))
    link.download = fileName
    link.click()
}

let jlabels = JSON.stringify(labels)
let jdata = JSON.stringify(data)

download(jlabels, 'labels.json', 'text/plain')
download(jdata, 'data.json', 'text/plain')
download(JSON.stringify({labels: labels, data:data}), 'all-data.json', 'text/plain')

Att, Messias Dias.

mega-regression's People

Contributors

messiasdias avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.