Home > Back-end >  Inport values from a csv file to netlogo patch excluding the first column
Inport values from a csv file to netlogo patch excluding the first column

Time:07-02

I have the followig issue. Below, you can find the code to "copy" values from a csv file to a patch-own feature (distances) row-by-row, as a list, according to the ID in item 0. Now, I don't want the number in item 0 (the ID) in this list, but only numbers from item 1 to the last column. Can anyone help me?

 file-open "distances.csv"
    while [ not file-at-end? ][
    let in-id item 0 data
    ask patches with [id = in-id] [
    set distances data]

CodePudding user response:

You don't include the actual reading of each line (row), but assuming that the line is being read in as a list, you can simply drop the first item in the list after you've recorded it.

file-open "distances.csv"
    while [ not file-at-end? ][
    let in-id item 0 data
    set data but-first data
    ask patches with [id = in-id] [
    set distances data]
  • Related