Set hard-coded delimiter (;) and escape char (") and better display

parsing errors
This commit is contained in:
Joshua Ramon Enslin 2023-01-18 01:31:36 +01:00
parent 543a80413c
commit 977e7511ec
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
4 changed files with 18 additions and 87 deletions

View File

@ -24,10 +24,22 @@ class CsvxmlValidator {
this.fieldList = Object.freeze(fieldList);
const data = Papa.parse(csvRaw.trim(), {header: true});
const data = Papa.parse(csvRaw.trim(), {
delimiter: ";", // auto-detect
escapeChar: '"',
skipEmptyLines: true,
header: true,
});
if (data.errors.length !== 0) {
window.alert(data.errors);
console.log("Errors encountered: ");
console.error(data.errors);
let msg = '';
for (let err of data.errors) {
msg += err.type + ': ' + err.message + "\n";
}
window.alert(msg);
}
let toValidate = data.data;

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css?v000008" />
<link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css?v000009" />
<link rel="manifest" href="/manifest.json" />
<meta name="theme-color" content="#aa4400" />
@ -27,7 +27,7 @@
</head>
<body class="loading">
<script src="assets/js/csvxmlV2.min.js?v000008" type="text/javascript" async></script>
<script src="assets/js/csvxmlV2.min.js?v000009" type="text/javascript" async></script>
</body>
</html>

View File

@ -7,7 +7,7 @@
declare(strict_types = 1);
require_once __DIR__ . "/../functions/functions.php";
const GET_PARAM_JS_CSS = "v000008";
const GET_PARAM_JS_CSS = "v000009";
/**
* Generates the json for a translation file.