[英]How I do convert a Julia stream to "byte content" for a Python package?
I maintain OdsIo.jl , a Julia package that wraps, for ods files specifically, ezodf , a Python package for various OpenDocument formats, I maintain OdsIo.jl , a Julia package that wraps, for ods files specifically, ezodf , a Python package for various OpenDocument formats,
My "ods_readall" function starts by calling ezodf.opendoc
.我的“ods_readall” function 从调用
ezodf.opendoc
开始。
ezodf.opendoc
supports as input, other than the filename, the file byte content itself: ezodf.opendoc
支持作为输入,除了文件名,文件字节内容本身:
ezodf.opendoc(filename)¶
Parameters: filename (str) – a filename or the file-content as bytes
Is there a way I can use it with a Julia stream (eg a network gzipped file as in this question ) intead of plain files?有没有办法可以将它与 Julia stream (例如这个问题中的网络压缩文件)而不是普通文件一起使用?
This seems to work, at least for HTTP, that is what I was interested to:这似乎有效,至少对于 HTTP,这就是我感兴趣的:
using HTTP, Pipe, PyCall
const pyio = PyNULL()
const ezodf = PyNULL()
copy!(pyio, pyimport("io"))
copy!(ezodf, pyimport("ezodf"))
function readstream(istream)
return ezodf.opendoc(pyio.BytesIO(istream))
end
urlData = "https://github.com/sylvaticus/OdsIO.jl/raw/master/test/spreadsheet.ods"
doc = @pipe HTTP.get(urlData).body |> readstream(_)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.