[Issue 17109] std.csv chokes on empty columns when parsing to struct

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jan 19 09:30:21 PST 2017


https://issues.dlang.org/show_bug.cgi?id=17109

--- Comment #4 from Jack Stouffer <jack at jackstouffer.com> ---
(In reply to Sophie from comment #3)
> It's a missing value, but in the case of numeric types a missing value is
> simply one example of a malformed value. I think the better approach in the
> code you used as an example would be to not expect the CSV logic to handle
> malformed floats. Use the CSV parser to extract strings, and then your code
> should assume responsibility for validating and handling malformed inputs.

The problem is, if I just get strings, then std.csv is useless because I can
just do this

    auto input = File("file.csv");
    auto data = input.byLine.map!(a => splitter(a, ','));

It would be faster too, as I'm just getting slices over byLine's buffer rather
than creating a new Tuple. But, returning T.init probably is a wrong choice
because int.init == 0.

Perhaps the replacement logic can be confined to nullable types and types with
nan?

--


More information about the Digitalmars-d-bugs mailing list