> In clojure, i can grab the first n lines nicely:
> (with-open [r (reader "FILE")] (str-join ", " (take n (line-seq r))))
>
> How can i grab the first n lines starting from an line offset? ex,
> grab lines 5 to 10 rather than just the first 5.
(with-open [r (reader "FILE")]
(str-join ", "
(take 5 (drop 5 (line-seq r)))))
This still does the work of finding all the \ns that you skip, of
course. Linewise navigation of a file is not as fast as seeking to
byte offsets.
> I can do this in java using traditional java way by using
> LineNumberReader's setLineNumber(int lineNumber) but i'm not sure how
> to interweave this in with clojure's file sequence operations.
(with-open [#^Reader r (reader "FILE")]
(with-open [lr (java.io.LineNumberReader. r)]
(.setLineNumber lr 5)
;; Your code here.
)))
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---