-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Differentiate between empty string and null value #81
Comments
@StefRe |
@StefRe It's maybe possible to have a case like the one you encountered. I'm very sorry, but I'll wait to deal with it until I get same feedback from others. |
Thanks for your reply.
However, it doesn't say anything about how to interpret the data, specifically it doesn't mention if an empty field should be an empty string or For my use case (a mock OpenCSV (
and allows to do exactly what I need:
So I can switch to OpenCSV but it's a bit heavy-weight as it does far more than I actually need so I'd prefer to stick with your lib for Kotlin projects. |
@StefRe |
I really want this feature... |
readAllWithHeader
yields aList<Map<String,String>>
and hence empty columns are being read as empty strings, so that we get""
for bothcol1
andcol2
in the following example:I'd really like to get
null
forcol2
here (this of course only makes sense if all strings are quoted, otherwise it wouldn't be clear how to interpret empty columns). I understand that you can't change the result toList<Map<String,String?>>
now, but maybe you could add anullCode
option for reading as it already exists for writing. The default value is an empty string""
(=current behavior). I could then simply doAt first glance it seems that it only requires to change
https://github.com/doyaaaaaken/kotlin-csv/blob/c23a51b98fbbcb1348b3928d561f1f5e11fba965/src/commonMain/kotlin/com/github/doyaaaaaken/kotlincsv/parser/ParseStateMachine.kt#L36-L48
to
and the same for https://github.com/doyaaaaaken/kotlin-csv/blob/c23a51b98fbbcb1348b3928d561f1f5e11fba965/src/commonMain/kotlin/com/github/doyaaaaaken/kotlincsv/parser/ParseStateMachine.kt#L87-L99
but I didn't check it thoroughly.
The text was updated successfully, but these errors were encountered: