Skip to content

Commit

Permalink
Only export errors.csv if there are any errors
Browse files Browse the repository at this point in the history
  • Loading branch information
VarunBarad committed Feb 5, 2024
1 parent f4e6f1d commit 8d6d2d7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ reportForm.addEventListener('submit', async (event) => {
}

const outputCsv = Papa.unparse(outputs) + '\n';
const errorsCsv = Papa.unparse(errors) + '\n';

downloadFile(outputCsv, 'output.csv');
downloadFile(errorsCsv, 'errors.csv');

if (errors.length > 0) {
const errorsCsv = Papa.unparse(errors) + '\n';
downloadFile(errorsCsv, 'errors.csv');
}
});

const downloadFile = (contents, fileName) => {
Expand Down

0 comments on commit 8d6d2d7

Please sign in to comment.