Giter VIP home page Giter VIP logo

Comments (3)

akash-akya avatar akash-akya commented on June 9, 2024 1

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.

christopherdbull avatar christopherdbull commented on June 9, 2024 1

Thank you! Got there in the end - via a bit of a practical education on iodata and streams in elixir 😅

from unzip.

akash-akya avatar akash-akya commented on June 9, 2024

I am closing this. But let me know if you still face issues.

from unzip.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.