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

Space around the delimiter in readdlm breaks the functionality of the quotes option #6

Open
yakir12 opened this issue Apr 8, 2017 · 1 comment
Labels

Comments

@yakir12
Copy link

yakir12 commented Apr 8, 2017

In readdlm (and readcsv), the quotes option allows for columns that are enclosed within double-quote (”) characters to contain new lines and column delimiters. But if there is a space before/after the delimiter, then readdlm either errors (unexpected character ' ' after quoted field) or doesn't parse the file as intended (number of rows is wrong), respectively:

a,b
c,"d, e"

results in a 2×2 Array{String,2}, good!

a,b
c, "d, e"

results in a 2×3 Array{String,2}, bad...

Because csv files are human-readable and humans usually put a space after a comma, maybe readdlm (or at least readcsv) should ignore spaces around delimiters?

@kshyatt kshyatt added the I/O label Apr 14, 2017
@strickek
Copy link

strickek commented Apr 15, 2017

I think the behavior is normal for Strings:
readdlm(IOBuffer("a,b"), ',') != readdlm(IOBuffer("a, b"), ',')
(even both are 1×2 Array{Any,2}: "b" != " b"
and therfore:
readdlm(IOBuffer("\"a,b\""), ',') gives 1×1 Array{Any,2}: "a,b"
readdlm(IOBuffer(" \"a,b\""), ',') gives 1×2 Array{Any,2}: " "a" "b""
The Error case is this:
readdlm(IOBuffer("\"a,b\" "), ',')
unexpected character ' ' after quoted field at row 1 column 1

@ViralBShah ViralBShah transferred this issue from JuliaLang/julia Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants