BioJulia / Libz.jl

Fast, flexible zlib bindings.
Other
27 stars 17 forks source link

define Base.nb_available #54

Closed tpapp closed 7 years ago

tpapp commented 7 years ago

Currently CSV.jl does not work with Libz inflated input streams (ie gzipped CSV files). @joshbode suggested a workaround:

Base.nb_available{T <: Libz.Source}(s::BufferedStreams.BufferedInputStream{T}) = eof(s) 

I don't know how general or efficient this is, but having something that has the same effect in the library would be nice.

joshbode commented 7 years ago

(cough) that should be !eof(s), which was my mistake in the forum :), e.g.

Base.nb_available{T <: Libz.Source}(s::BufferedStreams.BufferedInputStream{T}) = !eof(s)

It doesn't appear to affect the performance of CSV.jl at least, since as far as I can tell it is only used there once to determine whether the stream is already exhausted before getting the header line.

bicycle1885 commented 7 years ago

Close this issue. However, I'd rather recommend using CodecZlib.jl, which also supports nb_available, and TranscodingStreams.jl supports .bz2, .xz, .zstd, etc. with the same interface.