[ML] Fix for delimited data with whitespace in fields (#24899)

* [ML] Fix for delimted data with whitespace in fields

* rewriting to use papaparse transform function
This commit is contained in:
James Gowdy 2018-10-31 17:07:43 +00:00 committed by GitHub
parent b06b177eaa
commit fea42bada6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,15 +17,18 @@ export class CsvImporter extends Importer {
this.quote = results.quote;
this.hasHeaderRow = results.has_header_row;
this.columnNames = results.column_names;
this.shouldTrimFields = (results.should_trim_fields || false);
}
async read(csv) {
try {
const transform = this.shouldTrimFields ? (f => f.trim()) : (f => f);
const config = {
header: false,
skipEmptyLines: 'greedy',
delimiter: this.delimiter,
quoteChar: this.quote,
transform,
};
const parserOutput = Papa.parse(csv, config);