How can I write values in files for each turtle ? For example, I have 100 turtles and I would like to write data specific to each turtle in 100 files. For the moment, my code writes data for all turtles in one file .txt:
to write-locations-to-file
file-open "/home/reduan/IBM/outputs.txt"
ask turtles [
file-print (word who " ; " xcor " ; " ycor " ; " color " ; " [pcolor] of patch-here "\r\n" ) ]
end
Thanks in advance for your help.
I'm not sure what it is exactly that you are having trouble with, but you can just open a different file for each turtle. In the example below, I used the
who
number to generate different file names, but you could use some other method, as long as all file names are unique.