У меня есть два файла, один в JSON, а другой в MS-Excel.Оба файла должны иметь одинаковые данные, и я пытаюсь сравнить файлы.Я разработал эту вспомогательную функцию, которая должна помочь.Но скрипты не удается, он не может найти ни одного совпадения.Один пример: не удается сопоставить имена в одном случае со следующим журналом:
Имя ученика не соответствует: 993793117Имя в Json: Евгений, Тобиас: & Имя в Excel: Евгений, Тобиас:
Имена идентичны, и они идеально совпадают, если я скопирую имена из вышеупомянутой ошибки и сравню вручную.Как это можно решить?
this.fileComparisonXlJson = async function (Jsonfile, Excel){
let Datafile = Jsonfile;
await browser.wait(async function(){
return await fs.existsSync(Datafile);
}, 30*1000, "File has not downloaded in 30 seconds");
let rawdata = fs.readFileSync(await Datafile);
let data = await JSON.parse(rawdata);
let excelFile = await Excel;
await browser.wait(async function(){
return await fs.existsSync(excelFile);
}, 30*1000, "File has not downloaded in 30 seconds");
let WB = await Workbook.xlsx.readFile(await excelFile);
let WS = await WB.getWorksheet(1);
let RC = await WS.actualRowCount;
let a = 0;
for (j=0;j<(RC-1); j++){
jsonRecord = await data[j];
for (i=2; i<RC+1; i++){
const StudentID = 'A'+i;
if (await Number(WS.getCell(StudentID))===await Number(jsonRecord['StudentID'])){
const StudentName = 'B'+i;
const Grade = 'C'+i;
const BaseSchool = 'D'+i;
const RegTeacher = 'E'+i;
const EsyStatus = 'F'+i;
const EsySite = 'G'+i;
if (await WS.getCell(StudentName) === await jsonRecord['Student Name'].trim()) {
a = a;
}else{
a = a+ '\n Student Name did not match for :'+ jsonRecord['StudentID'] + 'Name in Json:'+ await jsonRecord['Student Name'].trim() + ': & Name in Excel:'+await WS.getCell(StudentName)+':' ;
}
if (await WS.getCell(Grade) === await jsonRecord['Grade']) {
a = a;
}else{
a = a+ '\n Grade did not match for :'+ jsonRecord['StudentID'];
}
if (await WS.getCell(BaseSchool) === await jsonRecord['Base School']) {
a = a;
}else{
a = a+ '\n Base School did not match for :'+ jsonRecord['StudentID'];
}
if (await WS.getCell(RegTeacher) === await jsonRecord['Registering Teacher']) {
a = a;
}else{
a = a+ '\n Reg Teacher did not match for :'+ jsonRecord['StudentID'];
}
if (await WS.getCell(EsyStatus) === await jsonRecord['Esy Status']) {
a = a;
}else{
a = a+ '\n ESY Status did not match for :'+ jsonRecord['StudentID'];
}
if (await WS.getCell(EsySite) === jsonRecord['Esy Site Assigned']) {
a = a;
}else{
a = a+ '\n ESY Site did not match for :'+ jsonRecord['StudentID'];
}
}else{
a = a+ '\n No Record found for the student :'+ jsonRecord['StudentID'] + ' in the Excel file';
}
}
}
return await a;
}