BurntSushi / rust-csv

A CSV parser for Rust, with Serde support.
The Unlicense
1.67k stars 215 forks source link

permit caller to define "nullable" semantics #167

Open BurntSushi opened 5 years ago

BurntSushi commented 5 years ago

Currently, the Serde deserializer in this crate hardcodes specific nullable semantics. Namely, only fields with an empty value are considered missing. But, it is fairly common in CSV formats to use other sentinels, such as "null," even for otherwise non-String fields. It should be possible to augment ReaderBuilder to permit the caller to provide a predicate that determines whether a field value is missing or not.

Once we have the predicate, it should be as simple as plumbing it through and calling it in deserialize_option.

See also https://users.rust-lang.org/t/serde-csv-empty-fields-are-the-string-null/31260 for motivation.

sify21 commented 1 year ago

mysql uses \N to denote null values.