Re: csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-03 Thread mw via Digitalmars-d-learn
On Monday, 3 October 2022 at 18:02:51 UTC, Salih Dincer wrote: On Sunday, 2 October 2022 at 19:48:52 UTC, mw wrote: ``` text.csvReader!Layout(["b","c","a"]); // Read only these column ``` The intention is very clear: only read the selected columns from the csv, and for any other fie

Re: csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-03 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 2 October 2022 at 19:48:52 UTC, mw wrote: ``` text.csvReader!Layout(["b","c","a"]); // Read only these column ``` The intention is very clear: only read the selected columns from the csv, and for any other fields of class Layout, just ignore (with the default D .init valu

Re: csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-03 Thread jmh530 via Digitalmars-d-learn
On Sunday, 2 October 2022 at 21:18:43 UTC, mw wrote: [snipping] A CSV library should consider all the use cases, and allow users to ignore certain fields. In R, you have to force `NULL` for `colClasses` for the other columns. In other words, the user has to know the number of columns of the

Re: csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-02 Thread rassoc via Digitalmars-d-learn
On 10/2/22 23:18, mw via Digitalmars-d-learn wrote: A CSV library should consider all the use cases, and allow users to ignore certain fields. Filed issue: https://issues.dlang.org/show_bug.cgi?id=23383 Let's see what others have to say.

Re: csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-02 Thread mw via Digitalmars-d-learn
On Sunday, 2 October 2022 at 21:03:40 UTC, rassoc wrote: But say, I'm curious, what's the purpose of adding an optional/useless contents field? What's the use-case here? We have a class/struct for a data record, some of its data fields need to be saved/loaded from CSV files; while there are

Re: csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-02 Thread rassoc via Digitalmars-d-learn
On 10/2/22 21:48, mw via Digitalmars-d-learn wrote: ```     text.csvReader!Layout(["b","c","a"]);  // Read only these column ``` The intention is very clear: only read the selected columns from the csv, and for any other fields of class Layout, just ignore (with the default D .init value)

Re: csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-02 Thread mw via Digitalmars-d-learn
``` text.csvReader!Layout(["b","c","a"]); // Read only these column ``` The intention is very clear: only read the selected columns from the csv, and for any other fields of class Layout, just ignore (with the default D .init value).

csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-02 Thread mw via Digitalmars-d-learn
Hi, I'm following the example on https://dlang.org/phobos/std_csv.html ``` class Layout { int value; double other; string name; int extra_field; // un-comment to see the error } void main() { import std.csv; import std.stdio: write, writeln,