[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:
parent
b06b177eaa
commit
fea42bada6
1 changed files with 3 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue