mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 23:04:26 +01:00
allow null values in csv
This commit is contained in:
parent
fda4f229bb
commit
bd2262ceea
@ -118,16 +118,26 @@ impl<W: io::Write + io::Seek> DocumentBatchBuilder<W> {
|
|||||||
for (value, (fid, ty)) in record.into_iter().zip(headers.iter()) {
|
for (value, (fid, ty)) in record.into_iter().zip(headers.iter()) {
|
||||||
let value = match ty {
|
let value = match ty {
|
||||||
AllowedType::Number => {
|
AllowedType::Number => {
|
||||||
value.parse::<f64>().map(Value::from).map_err(|error| {
|
if value.trim().is_empty() {
|
||||||
Error::ParseFloat {
|
Value::Null
|
||||||
error,
|
} else {
|
||||||
// +1 for the header offset.
|
value.trim().parse::<f64>().map(Value::from).map_err(|error| {
|
||||||
line: i + 1,
|
Error::ParseFloat {
|
||||||
value: value.to_string(),
|
error,
|
||||||
}
|
// +1 for the header offset.
|
||||||
})?
|
line: i + 1,
|
||||||
|
value: value.to_string(),
|
||||||
|
}
|
||||||
|
})?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AllowedType::String => {
|
||||||
|
if value.is_empty() {
|
||||||
|
Value::Null
|
||||||
|
} else {
|
||||||
|
Value::String(value.to_string())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
AllowedType::String => Value::String(value.to_string()),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.value_buffer.clear();
|
this.value_buffer.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user