diff --git a/scrape/parse.js b/scrape/parse.js index 8225636..e108929 100644 --- a/scrape/parse.js +++ b/scrape/parse.js @@ -63,11 +63,10 @@ export default async function parseThisShit(downloadedFilePath) { let classI = 0; for (const matchingKey of matchingKeys) { const allKeys = Object.keys(currentSheet).filter(key => key !== matchingKey && key.replace(/[a-z]/gi, '') == matchingKey.replace(/[a-z]/gi, '')); - - const final2 = []; + let final2 = []; for (const key of allKeys) { - const parsedKey = letterToNumber(key.replace(/[0-9]/gi, '')); + const parsedKey = letterToNumber(key.replace(/[0-9]/gi, '')) - 1; let d = true; try { @@ -83,6 +82,11 @@ export default async function parseThisShit(downloadedFilePath) { } } + final2 = Array.from(final2, item => item === undefined ? null : item); + while (final2.length < 10) { + final2.push(null); + } + final[finalIndex][classes[classI]] = final2.slice(1, 11);; classI++; @@ -113,6 +117,7 @@ export default async function parseThisShit(downloadedFilePath) { } finalIndex++; + return } const data = { @@ -144,4 +149,4 @@ export default async function parseThisShit(downloadedFilePath) { fs.writeFileSync('db/current.json', JSON.stringify(data)); } -// parseThisShit("downloads/table.xlsx"); +parseThisShit("downloads/table.xlsx");