Bug 23373 – add uda (e.g. @csvIgnore) support in std.csv to ignore some field

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-09-25T17:12:17Z
Last change time
2024-12-01T16:40:26Z
Assigned to
No Owner
Creator
mw
Moved to GitHub: phobos#9845 →

Comments

Comment #0 by mingwu — 2022-09-25T17:12:17Z
https://forum.dlang.org/post/[email protected] Currently std.csv can only handle basic scalar types, that is fine, but we need ways to allow user mark some (non-scalar) fields should be ignored: I'm trying this example: https://dlang.org/phobos/std_csv.html ``` struct Layout { string name; int value; double other; @csvIgnore Layout* parent; // add extra pointer } auto records = text.csvReader!Layout(';'); ``` Right now, if we add this extra pointer, the compiler will error out: https://run.dlang.io/is/EvU6Ee /dlang/dmd/linux/bin64/../../src/phobos/std/conv.d(223): Error: template std.conv.toImpl cannot deduce function from argument types !(Layout*)(string), candidates are: ... I think if we can add add uda (e.g. @csvIgnore) support in std.csv, it will make the library more flexible to use. I do run into this problem today, i.e. my struct need some extra non-simple-scalar fields (e.g. SysTime) other than those defined in the csv file, I'm wondering what kind of work-around people use in such situation? Run into this problem yet again: ``` class Foo { Foo[] foos; // how to mark this field to be csv ignored? } ``` Any work around? Thanks.
Comment #1 by robert.schadek — 2024-12-01T16:40:26Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9845 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB