Im trying to add variables to my turtles based on an Excel document. The excel document is just two columns with 19 random numbers. It is saved as a CSV. Im getting an error that says : Expected a literal value. (line number 19, character 2) error while turtle 17 running FILE-READ
However, all values are numbers in the document. This is the code
extensions [csv]
globals [ turtle-data ]
turtles-own [ awareness income housingtype adopt ]
to setup
clear-all
reset-ticks
create-turtles 20
ask turtles [
set color white
]
ask turtles [
setxy random-xcor random-ycor
]
; load-turtle-data
; setup-turtles
load-data
end
to load-data
file-open "Ejemplocsv.csv"
while [not file-at-end?] [
ask turtles [
set income file-read
set housingtype file-read
set size 1.5]
ask turtles [setxy random-xcor random-ycor]]
file-close
show "file read"
end
I also tried instead a code that another user posted here but got the same error. This part replaces the load-data. It doesn't work either.
to load-turtle-data
ifelse ( file-exists? "Ejemplocsv.csv" ) [
set turtle-data []
file-open "Ejemplocsv.csv"
while [ not file-at-end? ][
set turtle-data sentence turtle-data (list (list file-read file-read))
]
user-message "File loading complete!"
file-close
]
[
user-message "There is no input-data.txt file in current directory!"
]
end
to setup-turtles
foreach turtle-data [ iter ->
crt 1 [
set income item 0 iter
set housingtype item 1 iter
]
]
end
I just want to know the most effective way to load csv data, or excel, to the variable of my turtles.