Review of Jesse Phillips's CSV Parser

Jesse Phillips jessekphillips+D at gmail.com
Fri Oct 28 10:07:35 PDT 2011


Jacob Carlborg Wrote:

> If a header is specified, is it possible to iterate over the content as 
> an associative array, something like this:
> 
> string str = "a,b,c\nHello,65,63.63\nWorld,123,3673.562";
> auto records = csvText(str, ["b"]);
> 
> foreach (header, value ; records) {}
> 
> Or accessing a value by header:
> 
> foreach (record ; records)
> {
>      auto value = record["a"];
>      auto val = record.b; // perhaps using opDispatch as well
> }
> 
> -- 
> /Jacob Carlborg

If I implemented it this way then the entire record would be read in when a header exists.

auto records = csvText!(string[string])(str, ["b"]);

Would that be acceptable?


More information about the Digitalmars-d mailing list