Reading a csv file

Andrew nobody at nowhere.invalid
Thu Aug 9 18:39:32 PDT 2012


I'm trying to read in a csv file. The examples in the docs for std.csv 
all assume you're reading from a string rather than a file. 

This doesn't work: 

auto f = File(filename);
auto records = csvReader!int(f);

At this point it fails to compile with:

Error: template std.csv.csvReader does not match any function template 
declaration
Error: template std.csv.csvReader cannot deduce template function from 
argument types !(int)(File)
Error: template instance csvReader!(int) errors instantiating template

I assume this translates to "a file is not an acceptable form of input." 
Well, I know a string is, because the docs are written that way. But I'm 
not sure how to get a file into one big string, either; or if that's even 
the correct way to do it. 

Suggestions?

-- 
Andrew


More information about the Digitalmars-d-learn mailing list