Skip to content
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

Null versus Empty String fields #68

Open
agilmore30 opened this issue Feb 11, 2019 · 2 comments
Open

Null versus Empty String fields #68

agilmore30 opened this issue Feb 11, 2019 · 2 comments

Comments

@agilmore30
Copy link

Hi

First, thanks for an awesome piece of code. Very useful.

I am testing for null and empty string values. e.g.

Row 1 - "A",,"C" is returned by CSVReader as the string array [A","","C"]
Row 2 - "A","","C" is also returned as [A","","C"]

There doesn't seem to be any distinction between a null string and an empty string.

I would like row 1 to return as ["A",null,"B"]

Empty string and null can have different meanings in some applications.

Question 1. Is there a way to affect that behavior now ?
Question 2. If not, is it possible to add a constructor parameter or property, with some logic, to change the behavior.

Thanks - Adam

@agilmore30
Copy link
Author

I'm using 4.0.0

@fretje
Copy link
Contributor

fretje commented Feb 26, 2019

The CsvReader class actually has some constructors where you can supply a "nullvalue" parameter. This is by default an empty string. So that means that by default all empty strings are handled as null values. If you supply your own string there, e.g. "_null_" then only that string will be handled as a null value, and empty strings will be handled as empty strings.

See also #2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants