Netlogo 读取两个单独的CSV文件
目前我正在努力让我的netlogo读取两个不同的ckv文件来设置全局变量。我有两个文件需要读取每个刻度。请参阅我的代码:Netlogo 读取两个单独的CSV文件,netlogo,Netlogo,目前我正在努力让我的netlogo读取两个不同的ckv文件来设置全局变量。我有两个文件需要读取每个刻度。请参阅我的代码: to setup clear-all file-close-all ;; Close any files open from last run file-open "oil price.csv" file-open "co2 price.csv" setup-patches create-industries 25 ask industries [
to setup
clear-all
file-close-all ;; Close any files open from last run
file-open "oil price.csv"
file-open "co2 price.csv"
setup-patches
create-industries 25
ask industries [set shape "house"]
ask industries [set color red]
ask industries [move-to one-of patches with [pcolor = green] ]
ask industries [set oil-demand 1 + random-float 9]
create-ports 1
ask ports [set shape "pentagon"]
ask ports [set color yellow]
ask ports [setxy 0 0]
reset-ticks
end
to go
if file-at-end? [ stop ]
set oil-price csv:from-file "oil price.csv"
set co2-price csv:from-file "co2 price.csv"
;; model update goes here
if ticks = length "oil price.csv" [stop]
tick
end
我设法让它读取一个csv的石油价格,并改变其变量每滴答。但是,添加另一个不起作用。我想有一个单独的csv的石油价格,改变每个滴答声和相同的二氧化碳价格。我错过了什么?顺便说一下,我对netlogo还不熟悉。感谢大家的帮助!谢谢:)我记得csv扩展名读取最近打开的文件。因此,如果将每个
文件open
语句放在从文件读取的相应命令之前,它应该在它们之间交替
file-open "oil price.csv"
set oil-price csv:from-file "oil price.csv"
file-open "co2 price.csv"
set co2-price csv:from-file "co2 price.csv"