I\'m starting in netlogo these days, so I\'ve got some problems that I didn\'t find how to solve them. I have to read a huge .csv file, got this code on the web:
First of all, CSV means comma separated values with a point decimal separator, not semi-colon separated values with a comma decimal separator. See RFC 4180. Although some have resisted this for nationalistic reasons, the scientific community needs to adopt the existing standard. Agent-based modeling is part of the scientific community.
Now let's analyze what happen when you parse your file with this code. It reads the line as a string into your csv
variable. It sets $x to 20 and extract the substring up to the comma. The use of read-from-string treats "1;0;0;65;0;2;45;0;-0" as if it had been typed at the command center, so you just get the number 1
, since everything from the first semicolon onwards is a comment. The 1
is put into mylist
and the csv
variable is shortened to 018961934
. When this is read, you get 18961934
because NetLogo ignores the leading 0
.
This all happens because you do not have a real CSV file. So you need to use a real CSV file if you want to use this code to parse it.