0

I have an issue with load-data command. I manage to setup my model, shows up quite nicely. Then I need to load the data before I press "go". It does not work though and I have no idea why. So I already defined my turtles as part of the setup and by the following code, I am trying to give the turtles properties from the csv document, but it says: "Expected a literal value. (line number 1841, character 5) error while turtle 1606 running file-read called by procedure load-data called by button "load-data" " There are exactly 1841 respondents btw. I tried txt instead but no change. I ran out of ideas quite quickly.

Pretty please, does anyone have any idea what I might be doing wrong? I am quite new to this and pretty desperate since I am working completely on my own and my thesis advisor is not responding...

to load-data
  file-open "Pokus2.csv"
  while [not file-at-end?] [
   ask turtles [
      set n-turtles file-read
      set behaviour file-read
      set attitude file-read
      set size 1.5]
     ask turtles [setxy random-xcor random-ycor]
 ask turtles
  [if behaviour <= 0.33 [set pcolor red]
   if behaviour = 0.34 and behaviour < 0.66 [set pcolor orange]
   if behaviour >= 0.67 [set pcolor green]
  ]
    ]
  file-close
  show "file read"
end
  • Can you provide an example of what your text file looks like? I'm assuming it has three columns, or at least groups of three values, and 1831 rows- can you show in particular the last few rows (or a modified version thereof, if you have sensitive data)? – Luke C Feb 15 '19 at 21:14
  • 1831 0.5 0.47 1832 0.8 0.44 1833 0.7 0.4 1834 0.6 0.44 1835 0.75 0.56 1836 0.96 0.44 1837 0.96 0.52 1838 0.46 0.92 1839 0.58 0.88 1840 0.75 0.6 1841 0.5 0.68 These are the last 10 rows. So yeah, there are three columns and 1841 rows. No sensitive data. And I did not put the names of variables at the very beginning, so it's just numbers – Michaela Feb 16 '19 at 14:40
  • Ups, I do not know how to put it on the comment as such. But trust me, it's always three columns for each variable – Michaela Feb 16 '19 at 14:41
  • I managed to sort it out. I have no idea how though :D It felt like I just kept doing the same over and over. Could missing values have been an issue? Also, I uploaded it as txt... – Michaela Feb 16 '19 at 18:05

0 Answers0