I am having trouble with some basic IO operations using Clojure. I have a text file which I need to read, split with the "|" character, and enter into a list for later processing. Here are the contents of my text file:
1|John Smith|123 Here Street|456-4567
2|Sue Jones|43 Rose Court Street|345-7867
3|Fan Yuhong|165 Happy Lane|345-4533
And here is my current code:
((defn -main []
(println "Enter an option: \n")
(let [choice (read-line)]
(cond (= choice "1")
(let [cust-contents (slurp "file.txt")
nums-as-strings (clojure.string/split cust-contents #"|")
numbers (map read-string nums-as-strings)]
(print numbers)
)
)
) ) )
(-main)
I would think this code to work, however here is the error I get when running my program:
(; Execution error at user/eval7923$-main (REPL:11).
; EOF while reading
Could anyone please guide me on where I went wrong and on how to fix this?