practicalli / practicalli/clojure
Reading files lazily
Open
Nobody has claimed this yet.
lazyness
- Dominant language
- Makefile
- Stars
- 117
- Forks
- 36
- PR merge metrics
- No merged PRs in 30d
Description
Is there any way to count lines in un-gzipped file without slurp/reading it as a whole?
(ns gzip-playground
(:require [clojure.java.io :as io]
[clojure.string :as str])
(:import
(java.io StringReader BufferedReader ByteArrayOutputStream ByteArrayInputStream PrintWriter)
(java.util.zip GZIPOutputStream)
))
(->> (io/input-stream "https://wiki.mozilla.org/images/f/ff/Example.json.gz")
(java.util.zip.GZIPInputStream.)
(slurp)
(str/split-lines)
count
)
not sure how to get line-seq after this java.util.zip.GZIPInputStream. step
Just found a way that seems to work
(->> (io/input-stream "https://wiki.mozilla.org/images/f/ff/Example.json.gz")
(java.util.zip.GZIPInputStream.)
io/reader
line-seq
count
)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the issue's GZIPInputStream, io/reader, and line-seq example, then locate the repository documentation entry point for Clojure file-reading guidance. Done means the supported lazy-reading approach and its line-counting behavior are clearly documented, with any relevant documentation checks passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- tooling
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100