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

readdlm cannot read only part of a stream #10

Open
krcools opened this issue Apr 12, 2016 · 1 comment
Open

readdlm cannot read only part of a stream #10

krcools opened this issue Apr 12, 2016 · 1 comment
Labels
bug Something isn't working I/O

Comments

@krcools
Copy link

krcools commented Apr 12, 2016

The following code

s = """
1 2 3
4 5 6
start_other_section
"""

d = readdlm(IOBuffer(s), Int; dims=(2,3))

Results in an error being thrown:

ERROR: at row 4, column 1 : ErrorException("file entry \"start_other_section\" 
cannot be converted to Int64")) in error at error.jl:21

I assume this is being caused by readdlm continuing to read the stream beyond the declared dimensions of the array. Surely this can't be the intended behavior of readdlm with array dimensions specified. The situation above is quite common, e.g. in mesh file formats where there typically is a section containing vertices and one containing cells or faces.

This example was created using:

Julia Version 0.4.5
Commit 2ac304d (2016-03-18 00:58 UTC)
Platform Info:
  System: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Xeon(R) CPU E5-1620 v3 @ 3.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.3
@Keno Keno added the bug Something isn't working label Apr 12, 2016
@quinnj
Copy link
Member

quinnj commented Apr 19, 2016

FWIW, CSV.jl can parse this correctly:

julia> f = CSV.Source(IOBuffer(s);rows=2,header=0,delim=' ')
CSV.Source: <IOBuffer>
    CSV.Options:
        delim: ' '
        quotechar: '"'
        escapechar: '\\'
        null: ""
        dateformat: Base.Dates.DateFormat(Base.Dates.Slot[],"","english")
2x3 Data.Schema:
 Column1, Column2, Column3
   Int64,   Int64,   Int64


julia> r = Data.stream!(f, Data.Table)
Data.Table:
2x3 Data.Schema:
 Column1, Column2, Column3
   Int64,   Int64,   Int64
NullableArrays.NullableArray{T,1}[NullableArrays.NullableArray{Int64,1}[1,4],NullableArrays.NullableArray{Int64,1}[2,5],NullableArrays.NullableArray{Int64,1}[3,6]]

@kshyatt kshyatt added the I/O label Aug 2, 2016
@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
bug Something isn't working I/O
Projects
None yet
Development

No branches or pull requests

4 participants