Created
December 7, 2017 19:42
-
-
Save justinoboyle/0b3707a77c56c2094811c68f3b0a388a to your computer and use it in GitHub Desktop.
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
const table = $($('table.list')[0]) | |
const rows = $(table.children()[0]).children() | |
let countRow = 0 | |
let heading = [] | |
let grades = [] | |
for(let row of rows) { | |
let rowData = {} | |
let countCol = 0 | |
for(let col of $(row).children()) { | |
if(countRow < 1) { | |
let data = $(col).text() | |
if(data.includes('funct')) | |
data = data.split('funct')[0] | |
data = data.trim() | |
if(data.length > 0) | |
heading.push(data) | |
continue | |
} | |
if(heading[countCol]) { | |
let cn = $(col).text().replace(/(\r\n|\n|\r)/gm,"").replace(/ +(?= )/g,'').trim() | |
if(cn.startsWith('Close ')) | |
cn = cn.substring('Close '.length) | |
if(cn.endsWith('Close')) | |
cn = cn.substring(0, -1 * 'Close'.length) | |
rowData[heading[countCol]] = cn | |
} | |
countCol++ | |
} | |
if(Object.keys(rowData).length > 0) | |
grades.push(rowData) | |
rowData = {} | |
countRow++ | |
} | |
console.log(grades) // use this somewhere |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment