I am new to clojure. I am trying to write a program which reads data from a file (comma seperated file) after reading the data I am trying to split each line while delimiter "," but I am facing the below error:
CompilerException java.lang.NullPointerException, compiling:(com\clojure\apps\StudentRanks.clj:26:5)
Here is my code:
(ns com.clojure.apps.StudentRanks)
(require '[clojure.string :as str])
(defn student []
(def dataset (atom []))
(def myList (atom ()))
(def studObj (atom ()))
(with-open [rdr (clojure.java.io/reader "e:\\example.txt")]
(swap! dataset into (reduce conj [] (line-seq rdr)))
)
(println @dataset)
(def studentCount (count @dataset))
(def ind (atom 0))
(loop [n studentCount]
(when (>= n 0)
(swap! myList conj (get @dataset n))
(println (get @dataset n))
(recur (dec n))))
(println myList)
(def scount (count @dataset))
(loop [m scount]
(when (>= m 0)
(def data(get @dataset m))
(println (str/split data #","))
(recur (dec m))))
)
(student)
Thanks in advance.
defwithin functions, uselet.