feat: autodetect "$ as newlines" hack in both OBSVER1 and OBSVER2
This commit is contained in:
parent
f013ab4263
commit
0b830601f5
|
@ -11,7 +11,18 @@ function _parseFloat(token) {
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceDollarNewlinesHack(body) {
|
||||||
|
// see if we are using the hack with $ as newlines, replace them for the csv parser
|
||||||
|
if (body.endsWith('$')) {
|
||||||
|
return body.replace(/\$/g, '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
function addPointsToTrack(trackInfo, body, format = null) {
|
function addPointsToTrack(trackInfo, body, format = null) {
|
||||||
|
body = replaceDollarNewlinesHack(body);
|
||||||
|
|
||||||
const detectedFormat = format != null ? format : detectFormat(body);
|
const detectedFormat = format != null ? format : detectFormat(body);
|
||||||
|
|
||||||
let parser;
|
let parser;
|
||||||
|
@ -60,10 +71,6 @@ function detectFormat(body) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function* parseObsver1(body) {
|
function* parseObsver1(body) {
|
||||||
if (body.indexOf('\n') < body.length - 1) {
|
|
||||||
body = body.replace(/\$/g, '\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const record of csvParse(body, {
|
for (const record of csvParse(body, {
|
||||||
delimiter: ';',
|
delimiter: ';',
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
|
|
Loading…
Reference in a new issue