1

This is what I have so far:

(defn cities []
    (with-open [rdr (reader)]
        (doseq [line (next (line-seq rdr))]
            (print line))))

I am able to print all the rows minus the first but am unable to return all the rows? How would I be able to do this

Richard Desouza
  • 249
  • 4
  • 13
  • 2
    Possible duplicate of [Read a file in clojure and ignore the first line?](https://stackoverflow.com/questions/19013616/read-a-file-in-clojure-and-ignore-the-first-line) – Robert Moskal Nov 14 '19 at 03:37

1 Answers1

2

Do you see that (next (line-seq rdr)) part? That's returning the list without the first item. Instead of printing it, you can just return it.

Here, however, you have to make sure that it is fully realized before the reader is closed. You can do that with doall:

(defn cities []
  (with-open [rdr (reader)]
    (doall (next (line-seq rdr)))))
Svante
  • 50,694
  • 11
  • 78
  • 122