how to access record[0] of a csv row? Error: no [] operator overload for type CsvRecord!(int, cast(Malformed)1, string, dchar)

Paul Backus snarwin at gmail.com
Mon Dec 7 03:51:02 UTC 2020


On Monday, 7 December 2020 at 02:25:23 UTC, mw wrote:
> onlineapp.d(8): Error: no [] operator overload for type 
> CsvRecord!(int, cast(Malformed)1, string, dchar)
>
> should `r`'s type be integer array? and how do I access each 
> elelment of the row?
>
> Thanks.

The docs [1] say that csvReader returns an input range, not an 
array. Input ranges don't support indexing, only iteration (e.g. 
with `foreach`). If you want an array, you will have to use 
`std.array.array` to create one.

[1] http://phobos.dpldocs.info/std.csv.csvReader.1.html


More information about the Digitalmars-d-learn mailing list