csv - 如何将 CSV 文件中的股票数据读取到 netlogo 中?

标签 csv netlogo stock

我想将股票历史数据加载并读取到netlogo中,我发现how to read a .CSV file with netlogo非常有帮助。

但是,为了实现我所需要的,我仍然需要进入fileList的每个元素列表(参见上面的链接),并提取元素列表的每个元素并将它们存储到不同的列表中如datesopenPriceshighPrices等。

谁能告诉我如何实现它?或者指出一些代码示例也非常有帮助。我刚刚开始学习netlogo,所以还有很多东西需要补。

非常感谢!

股票历史数据如下所示

2015/12/15, 12, 12.9, 11.99, 12.5, 10000

2015/12/16, 12.1, 13.9, 11.99, 12.8, 11000

globals[eachLine dates openPrices highPrices lowPrices closePrices volumes]

to openFile
  file-open "jqr.txt"
  set dates []
  set openPrices []
  set highPrices []
  set lowPrices []
  set closePrices []
  set volumes []

  set fileList []

  while [not file-at-end?] [
    set csv file-read-line
    set csv word csv ","  ; add comma for loop termination 

    let mylist []  ; list of values 
    while [not empty? csv] 
    [
      let $x position "," csv 
      let $item substring csv 0 $x  ; extract item 
      carefully [set $item read-from-string $item][] ; convert if number 
      set mylist lput $item mylist  ; append to list 
      set csv substring csv ($x + 1) length csv  ; remove item and comma 
    ] 
    set fileList lput mylist fileList
  ]

  ;; ??????
  foreach fileList 




  show fileList
  file-close
end

最佳答案

尝试 NetLogo 的 csv extension .

关于csv - 如何将 CSV 文件中的股票数据读取到 netlogo 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34313328/

相关文章:

R将数据帧列写入具有前导零的csv

class - 是否可以在 NetLogo 中创建类?

r - R中嵌套循环的性能缓慢

python - 使用csv从mysql数据库导出数据

r - 使用 R 将 jpg 转换为灰度 csv

python - .FITS 文件/表格转为 csv?

hyperlink - NETLOGO:制作具有精确链接数的网络

netlogo - 如何将数字列表的值与 netlogo 中的名称列表中的项目相匹配?

php - 如何在 Magento 中手动更新库存数量

python - 使用 python 下载股票和期权数据