Comments (3)
Hey @christopherdbull
Zip.file_stream!/2
returns stream of iodata not binary/string. This is an optimization to avoid building intermediate binary if you are forwarding it to some other IO operation. Most IO operations in elixir/erlang work with iodata to take benefit of this, you can read more about it here. The documentation should mention that chunks are iodata. I will update it to clarify.
But if your usecase wants binary/string then you can just convert using IO.iodata_to_binary
binary_stream =
Unzip.file_stream!(zipfile, "foo.csv")
|> Stream.map(&IO.iodata_to_binary/1)
# if you want the whole csv file as string
csv = Enum.into(binary_stream, "")
# if you want csv as list of strings
csv_lines = Enum.to_list(binary_stream)
from unzip.
Thank you! Got there in the end - via a bit of a practical education on iodata and streams in elixir 😅
from unzip.
I am closing this. But let me know if you still face issues.
from unzip.
Related Issues (8)
- Warning on Elixir v1.14 HOT 2
- Dialyzer/linting improvement: define a @type t for the %Unzip{} struct HOT 1
- Feature: Support for Gzip HOT 2
- Remove warning HOT 4
- Invalid zip file, missing EOCD record but unzip -t returns okay HOT 4
- Unzip from memory? HOT 2
- Suggestions of improvements for the project HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unzip.