# What is the recommended way to decorate an IO stream with a filter in Julia

**URL:** <https://discourse.julialang.org/t/what-is-the-recommended-way-to-decorate-an-io-stream-with-a-filter-in-julia/29226>\
**Category:** Performance\
**Tags:** question\
**Created:** [September 27, 2019, 11:45am UTC](https://discourse.julialang.org/t/what-is-the-recommended-way-to-decorate-an-io-stream-with-a-filter-in-julia/29226 "2019-09-27T11:45:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pszufe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pszufe/32/23452_2.png) [@pszufe](https://discourse.julialang.org/u/pszufe)\
**Post date:** [September 27, 2019, 11:45am UTC](https://discourse.julialang.org/t/what-is-the-recommended-way-to-decorate-an-io-stream-with-a-filter-in-julia/29226/1 "2019-09-27T11:45:28Z")

</div>

What is the recommended way to decorate a IO stream with a filter?

One great example of stream decorators is `CodecZlib.jl` that provides compression and decompression decorators for output and input streams respectively.  
However, I could not find decorators for stream filtering. For an example in the standard Java library we have  
`java.io.FilterInputStream` and `java.io.FilterOuputStream`.

Of course I could extend the `IO` type and provide my own implementation but I assume there is already some package for that?

Sample use case could having a 100GB file that I want to filter in-flight before it gets to functions such as `CSV.read`. It is easy to do when saving a temporary file and then loading by `CSV.read` but this something I would like to avoid.

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [September 27, 2019, 1:34pm UTC](https://discourse.julialang.org/t/what-is-the-recommended-way-to-decorate-an-io-stream-with-a-filter-in-julia/29226/2 "2019-09-27T13:34:40Z")

</div>

I think a custom codec with [https://github.com/bicycle1885/TranscodingStreams.jl](https://github.com/bicycle1885/TranscodingStreams.jl) should work for you.
