[ML] When importing CSV through file data viz, omit empty values (#39524)

CSV cannot distinguish between null and empty string.
Empty CSV values in numeric and date fields are better
considered as null rather than empty string, as empty
strings are rejected by Elasticsearch for these mapping
types. For consistency this change omits all empty
values from CSV records from the derived JSON document.

Fixes #39240
This commit is contained in:
David Roberts 2019-06-25 06:36:15 +01:00 committed by GitHub
parent fbcd355f6c
commit a139020c56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,7 +64,9 @@ function formatToJson(data, columnNames) {
const line = {};
for (let c = 0; c < columnNames.length; c++) {
const col = columnNames[c];
line[col] = data[i][c];
if (data[i][c] !== undefined && data[i][c] !== '') {
line[col] = data[i][c];
}
}
docArray.push(line);
}