[Issue 17109] std.csv chokes on empty columns when parsing to struct
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Jan 20 13:09:58 PST 2017
https://issues.dlang.org/show_bug.cgi?id=17109
Jon Degenhardt <jrdemail2000-dlang at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jrdemail2000-dlang at yahoo.co
| |m
--- Comment #6 from Jon Degenhardt <jrdemail2000-dlang at yahoo.com> ---
There is no standard behavior for empty fields in CSV. Pragmatically, it's an
application level decision, meaning that the application that generated the CSV
chose what the meaning is, and the application reading it needs to respect
this. Different higher level packages make their own choices of course.
R, for example, treats empty empty fields as "NA", meaning "Not Applicable" or
"Missing". This is a numeric value similar to but distinct from NaN (R borrows
a bit from floats and integers to do this). See R's read.table documentation.
Pandas treats empty as missing, but uses NaN to represent it. See "Working with
missing data" in the Pandas documentation
(http://pandas.pydata.org/pandas-docs/stable/missing_data.html), and the
pandas.read_csv documentation.
The real key though is that most of these CSV readers provide options
controlling interpretation. Depending on use case, error, NaN or some other
behavior may be warranted. D's CSV reader would benefit from having similar
control.
--
More information about the Digitalmars-d-bugs
mailing list