【问题标题】:How to read stock data in CSV file into netlogo?如何将 CSV 文件中的股票数据读入 netlogo?
【发布时间】:2015-12-16 22:16:01
【问题描述】:

我想将股票历史数据加载并读取到 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

【问题讨论】:

    标签: csv netlogo stock


    【解决方案1】:

    试用 NetLogo 的csv extension

    【讨论】:

    • 谢谢艾伦,我去看看。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-23
    相关资源
    最近更新 更多