-
Notifications
You must be signed in to change notification settings - Fork 2
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
readdlm not working with white spaces #1
Comments
Well it shouldn't crash... but at least there's a workaround (especially useful for larger files): |
Can you provide an example file and invocation that exhibits this crash? |
@StefanKarpinski Shure, The file content is
Note that the first character is a whitespace. Using this invocation
I get the following error
This invocation provides something I dint spect
And the one that works is
This is a minimal working example, but it seems to happen in more complicated cases too. |
That's not what we would call a "crash", it's an error message indicating that the file doesn't have valid formatting. The error message isn't great (it reads an empty field before the leading space and then cannot convert that to float), but |
I guess it needs an option to skip empty fields? |
One option that would be very helpful is to skip empty fields as @JeffBezanson said or, which I think it is better, to consider multiple delimiter chars as one single separator. There are some space index files that has this kind of format:
DelimitedFiles.jl seems to be not capable of parsing it correctly. However, if there is an option like |
I didn't check, but if this works with CSV.jl and/or (the maybe less known) DLMReader.jl, then maybe not bother implement this (and document both, at least those of where this works)? They at least load fast now:
CSV.jl took slightly longer with auto though. Maybe a fluke. |
readdlm ignores all-white spaces by default when a delimiter is not specified. However, when one wants to specify the data type to be read it is obligatory to specify the delimiter too...
readdlm(source, delim::AbstractChar, T::Type, eol::AbstractChar; header=false, skipstart=0, skipblanks=true, use_mmap, quotes=true, dims, comments=false, comment_char='#')
Then, in the following case,
readdlm(file, ' ', Float64, comments=true)
the function doesn't ignore the initial whitespace because the delimiter is
' '
, only 1 whitespace. Then the program crashes with for exampleThere should be a flag to ignore all chars that match with the delimiter or just be able to specify the type like this
readdlm(file, type=Float64, comments=true)
however this brings the problem that if the delimiter is not a whitespace the problem will persist.
The text was updated successfully, but these errors were encountered: