NetLogo: Is there a way to customize CSV files generated by export-plot to only include certain columns?

前端 未结 2 724
栀梦
栀梦 2021-01-14 15:40

This might seems really basic , but using export plot feature of NetLogo what I get is something like this:

x,y,color,pen down?,x,y,color,pen down?,x,y,color         


        
相关标签:
2条回答
  • 2021-01-14 15:58

    In a word, no.

    Someone could write an extension that provides this.

    0 讨论(0)
  • 2021-01-14 16:16

    Actually, there is a workaround using the built-in csv extension (see https://ccl.northwestern.edu/netlogo/docs/csv.html). All you have to do is to build an array to programmatically gather the same information displayed in the plots and that can be written to a csv file later on as follows (I usually use a button for this purpose):

    extensions [array csv]
    
    to write-csv
      let csv-delimiter ";"
      let output [[ "x" "val1" "val2" ]]
      set output lput [ 1 2 3 ] output
      set output lput [ 4 5 6 ] output
      (csv:to-file "c:/temp/filename.csv" output csv-delimiter)
    end  
    

    This will result in the following csv file:

    x;val1;val2
    1;2;3
    4;5;6
    

    To write your model outputs to a file, you could construct the array output in your setup procedure and add each line of data in your go procedure (with your model time unit being the value for x).

    Please be aware that I changed the csv delimiter to ';' instead of ',' in my example in order to be able to open the file in a German-language version of Microsoft Excel.

    0 讨论(0)
提交回复
热议问题