【问题标题】:netlogo export to csvnetlogo 导出到 csv
【发布时间】:2018-09-22 17:47:06
【问题描述】:

我是 NetLogo 的新手,所以这可能是一个愚蠢的问题。 当我尝试将海龟、补丁、全局变量导出到单独的 CSV 文件时,这个可以:

csv:to-file "turtles.csv" [ (list xcor ycor color shape) ] of turtles

但以下两个没有:

csv:to-file "patches.csv" [ (list xcor ycor cluster-number) ] of patches 错误:此代码不能由补丁运行,只能由海龟运行

csv:to-file "statistics.csv" (list meet meet-agg meetown meetown-agg meetother meetother-agg coopown coopown-agg coopother coopother-agg defown defown-agg defother defother-agg) 错误:扩展异常:应为列表列表,但 1016 是其中一个元素。

有人可以帮我吗?提前致谢!

【问题讨论】:

  • 嗨,卢!欢迎来到 StackOverflow!我试图在下面的回答中猜测您的问题是什么,但总的来说,提出问题时的一个好的经验法则是尝试提供更多关于正在发生的事情的细节。在您的情况下,告诉我们您收到了哪些错误消息,而不是仅仅说明事情不正常,这将有助于我们更好地诊断您的问题。如果需要,您可以随时编辑您的问题并添加更多详细信息。

标签: csv netlogo


【解决方案1】:

关于:

csv:to-file "patches.csv" [ (list xcor ycor cluster-number) ] of patches

我猜唯一的问题是您尝试使用 xcorycor,它们是海龟变量,而不是 pxcorpycor,它们是补丁变量。你需要:

csv:to-file "patches.csv" [ (list pxcor pycor cluster-number) ] of patches

至于这个:

csv:to-file "statistics.csv" (list meet meet-agg meetown meetown-agg meetother meetother-agg coopown coopown-agg coopother coopother-agg defown defown-agg defother defother-agg)

要记住的一件事是csv:to-file 需要一个“列表列表”,而您的代码会生成一个列表,这很可能是问题所在。如果所有这些变量都是全局变量,并且您只想将它​​们放在 CSV 文件中的一行中,则可以将列表包装在另一个列表中:

csv:to-file "statistics.csv" (list (list meet meet-agg meetown meetown-agg meetother meetother-agg coopown coopown-agg coopother coopother-agg defown defown-agg defother defother-agg))

但如果没有更多信息,很难准确诊断您的问题。你能告诉我们是什么让你认为它不起作用吗?你想做什么?

【讨论】:

  • 谢谢尼古拉斯!这些正是我需要的!对于不清楚的问题,我们深表歉意。
  • 别担心!很高兴我能帮上忙!
  • @LuYang - 嗨,Lu,欢迎来到 Stack Overflow!如果 Nicolas 的回答解决了您的问题,请点击他的回答旁边的小复选标记框,将此问题标记为已关闭。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-12-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-17
  • 2017-02-20
  • 2012-12-19
相关资源
最近更新 更多