News for hackers. Stuff that matters.
Re:Is it time to stop using sentinel values for null / “NA” ... by msla on Monday June 05, 2023 @05:25PM (#36203908)
How do I represent an Option<Int> in a CSV file?
Re:Is it time to stop using sentinel values for null / “NA” ... by smcin on Monday June 05, 2023 @05:33PM (#36204056)
I assume you mean the Scala type Option<Int>, and that's an integer type which can be NaN, right?
Re:Is it time to stop using sentinel values for null / “NA” ... by msla on Monday June 05, 2023 @06:21PM (#36204869)
No, I only used Option<Int> because the person I replied to did, and I don't expect them to know what Maybe Int means.
Re:Is it time to stop using sentinel values for null / “NA” ... by deathanatos on Monday June 05, 2023 @05:48PM (#36204351)
I mean … CSV hasn't a notion of Option, or Int, so you'd have to define your own.

But you don't have to use what the article calls a "sentinel value" (i.e., you don't have to dedicate -2489391827 as "null") to do it: simply "null" for None/Null/Nothing, and the integer for Some(<int>) / Just int would work.

Re:Is it time to stop using sentinel values for null / “NA” ... by icedchai on Monday June 05, 2023 @06:22PM (#36204887)
An empty string could be interpreted as a null integer.

Now how do you do that with a string? If you have to ask these questions, CSV is probably not the right format.