www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17109] New: std.csv chokes on empty columns when parsing to

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

          Issue ID: 17109
           Summary: std.csv chokes on empty columns when parsing to struct
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: jack jackstouffer.com

import std.csv;
import std.typecons;
import std.stdio;

static immutable csv_string = "aaa,1.1,bbb\nstring,,another string";

void main() {
    foreach(record; csvReader!(Tuple!(string, float, string))(csv_string))
    {
        writeln(record[0], record[1], record[2]);
    }
}

std.csv.CSVException /opt/compilers/dmd2/include/std/csv.d(1096): Floating
point conversion error for input "".


It should return T.init when it encounters an empty string.

--
Jan 19