www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15545] New: csv Reader line feed '\r' failure

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

          Issue ID: 15545
           Summary: csv Reader line feed '\r' failure
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: gruen_tobias web.de

If a file uses '\r' line feeds and the last character is a linefeed 
(empty line after the data)
Csv Reader will throw a exception at the end of the file.
In case of '\n' or "\r\n" as line-feed this is not the case.

// Will fail
enum failData = 
"name, surname, age
Joe, Joker, 99\r";

enum nonFailData = 
"name, surname, age
Joe, Joker, 99\r\n";

import std.csv, std.stdio;

void main(string[] args)
{
    auto reader = csvReader(failData);

    foreach(entry; reader)
    {
        writeln(entry);
    }
}


togrue

--
Jan 10 2016