This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
const XLSX = require('xlsx');
|
||||
const fs = require("fs");
|
||||
const parseAbsence = require('./utils/parseAbsence');
|
||||
const parseTeachers = require('./utils/parseTeachers');
|
||||
|
||||
function parseThisShit(downloadedFilePath) {
|
||||
async function parseThisShit(downloadedFilePath) {
|
||||
const workbook = XLSX.readFile(downloadedFilePath);
|
||||
const sheetNames = workbook.SheetNames;
|
||||
|
||||
@@ -60,7 +62,7 @@ function parseThisShit(downloadedFilePath) {
|
||||
// For each class
|
||||
let classI = 0;
|
||||
for (const matchingKey of matchingKeys) {
|
||||
const allKeys = Object.keys(currentSheet).filter(key => key !== matchingKey && key.endsWith(matchingKey.replace(/[a-z]/gi, '')));
|
||||
const allKeys = Object.keys(currentSheet).filter(key => key !== matchingKey && key.replace(/[a-z]/gi, '') == matchingKey.replace(/[a-z]/gi, ''));
|
||||
|
||||
const final2 = [];
|
||||
|
||||
@@ -86,6 +88,24 @@ function parseThisShit(downloadedFilePath) {
|
||||
classI++;
|
||||
}
|
||||
|
||||
// ABSENCE
|
||||
final[finalIndex]["ABSENCE"] = [];
|
||||
const absenceKey = Object.keys(currentSheet).find(key => {
|
||||
const value = (typeof currentSheet[key].v == "string" ? currentSheet[key].v : "").trim().toLowerCase();
|
||||
return value == "absence";
|
||||
});
|
||||
const teacherMap = await parseTeachers();
|
||||
const allAbsenceKeys = Object.keys(currentSheet).filter(key => key !== absenceKey && key.replace(/[a-z]/gi, '') == absenceKey.replace(/[a-z]/gi, ''));
|
||||
for (const absenceKeyCur of allAbsenceKeys) {
|
||||
const value = currentSheet[absenceKeyCur]["v"].trim();
|
||||
if (value.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const data = parseAbsence(value, teacherMap);
|
||||
final[finalIndex]["ABSENCE"].push(data);
|
||||
}
|
||||
|
||||
finalIndex++;
|
||||
}
|
||||
|
||||
@@ -119,3 +139,5 @@ function parseThisShit(downloadedFilePath) {
|
||||
}
|
||||
|
||||
module.exports = parseThisShit;
|
||||
|
||||
// parseThisShit("downloads/table.xlsx");
|
||||
|
||||
Reference in New Issue
Block a user