Consolidate parser args

This commit is contained in:
Dannon Baker
2022-09-21 14:36:20 -04:00
parent ff1309fefa
commit 446b3ccdbf
+5 -6
View File
@@ -143,6 +143,9 @@ var TabularDatasetChunkedView = Backbone.View.extend({
this.loading_chunk = false;
// Configure delimiter for parsing data
this.delimiter = this.model?.attributes?.file_ext === "csv" ? "," : "\t";
this.parseArgs = {
delimiter: this.delimiter,
};
// load trackster button
new TabularButtonTracksterView({
model: options.model,
@@ -316,9 +319,7 @@ var TabularDatasetChunkedView = Backbone.View.extend({
var data_table = this.$el.find("table");
let parsedChunk = [];
try {
parsedChunk = parse(chunk.ck_data, {
delimiter: this.delimiter,
});
parsedChunk = parse(chunk.ck_data, this.parseArgs);
} catch (error) {
// If this blows up it's likely data in a comment or header line
// (e.g. VCF files) so just split it by newline first then parse
@@ -326,9 +327,7 @@ var TabularDatasetChunkedView = Backbone.View.extend({
parsedChunk = chunk.ck_data.trim().split("\n");
parsedChunk = parsedChunk.map((line) => {
try {
return parse(line, {
delimiter: this.delimiter,
})[0];
return parse(line, this.parseArgs)[0];
} catch (error) {
// Failing lines get passed through intact for row-level
// rendering/parsing.