Skip to content

Commit

Permalink
Add logging & error handling to parseCSVEntries function
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvNC committed Jan 19, 2024
1 parent 2953d6e commit f888348
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/util/parseCsvEntries.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,33 @@ async function parseCSVEntries(allCsvPath) {
* @type {DictionaryEntry[]}
*/
const dictionaryEntries = [];
let unpublishedCount = 0;
let noDataCount = 0;
let unreviewedCount = 0;
for (const entry of data) {
if (entry.entry === '未有內容 NO DATA') {
noDataCount++;
continue;
}
if (
entry.warning.includes(
'未經覆核,可能有錯漏 UNREVIEWED ENTRY - MAY CONTAIN ERRORS OR OMISSIONS'
)
) {
continue;
unreviewedCount++;
}
if (entry.public !== '已公開') {
unpublishedCount++;
}
try {
const parsedEntry = parseEntry(entry);
dictionaryEntries.push(parsedEntry);
} catch (error) {
console.log(`Error parsing entry ${entry.id}: ${error.message}`);
}
const parsedEntry = parseEntry(entry);
dictionaryEntries.push(parsedEntry);
}
console.log(`Parsed ${dictionaryEntries.length} entries`);
console.log(`Skipped ${noDataCount} no data entries`);
return dictionaryEntries;
}

Expand Down

0 comments on commit f888348

Please sign in to comment.