How do I import data from a CSV file and convert it line-by-line so I can use it in my program? I want it to be a string but I keep getting error messages that it is still a list or a list of lists.
I am trying to copy the example given in the Netlogo User Manual for reading a file one line per tick (see below). I created a simple example.
extensions [CSV]
globals [date]
to setup
clear-all
file-close-all
file-open "S&PDate.csv"
set date current-date
reset-ticks
end
to go
if file-at-end? [stop]
set date current-date
tick
end
to-report current-date
file-open "S&PDate.csv"
let result csv:from-row file-read-line
while [ not file-at-end? ] [
let row csv:from-row file-read-line
set result (map result row)
]
file-close
report result
end