-
Notifications
You must be signed in to change notification settings - Fork 22
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
Not quoted empty strings are now null, implement a trim-blanks options. #12
Conversation
I am sorry to have missed this... I will look at this post-haste |
Looking at the whitespace tests, this seems to be a bug you have discovered rather than a feature that needs to be added. We already do not trim quoted values, but unfortunately this was missed on white-space only strings. I think I will leave it returning nil for empty quoted values, but otherwise we should be returning the spaces always. (It is relatively easy to trim after the fact and the semantics are easier to understand if "everything in quotes is returned"). |
Never mind I miss read, apologies, applying now |
This should be fixed in 982931d Note that I changed the var/arg to |
Apologies again for missing this, github didnt notify me and It was not on my github dashboard (though I am unsure why). |
In fact, if I'm reading your commit correctly, what you did is not helping my use case at all. I need to be able to distinguish in between those two cases, which have different representations in databases:
So in my pull request what I had done is to provide a way to distinguish between no value between separators (raises To be able to do that, you also have to consider whether |
I just committed a patch that I think covers all the circumstances discretely. Please let me know if this now meets your needs |
As a note there was a bug in the tests related to lisp-unit2 that I have fixed. |
Looks pretty good, thanks! will integrate tomorrow, I guess. |
Thanks to the work at AccelerationNet/cl-csv#12 we can now use the main branch of cl-csv again.
When loading data from CSV file into a database (PostgreSQL in my case), it's important to be able to distinguish in between empty string and NULL values. This patch considers non-quoted empty strings as NIL.
Also, it's quite important to be able to retain blanks found around non-quoted values, so I also implemented a new option trim-blanks that works as shown here:
I've made the previous behaviour the default, that is trim-blanks defaults to
t
. I don' t think the unquoted empty string toNIL
behavior needs an option, though.