dryk50495 2014-09-30 17:04
浏览 171

Quandl API CSV文件仅返回列标题

I am trying to do a simple pull from the Quandl Data API for stock price information. I have found the following URL from their documentation that should pull the stock data for AAPL stock - https://www.quandl.com/api/v1/datasets/WIKI/AAPL.csv?trim_start=2013-12-25&trim_end=2013-12-31

If I load this URL in the browser I get the csv file just fine. However, if I try to pull the file using php, I only get the column headers of the file. Here is my code:

$url = "https://www.quandl.com/api/v1/datasets/WIKI/AAPL.csv?trim_start=2013-12-25&trim_end=2013-       12-31";
$fp = fopen($url,'r') or die("can't open file");
$csv_array = (fgetcsv($fp));
print_r ($csv_array);

And this returns - Array ( [0] => Date [1] => Open [2] => High [3] => Low [4] => Close [5] => Volume [6] => Ex-Dividend [7] => Split Ratio [8] => Adj. Open [9] => Adj. High [10] => Adj. Low [11] => Adj. Close [12] => Adj. Volume )

But those are just the column headers from the csv file. It doesn't contain any of the actual data.

Anyone know what might be going on here?

Thank you, Dylan

  • 写回答

1条回答 默认 最新

  • dongyuan1902 2014-09-30 20:56
    关注

    you need to loop, test the next code:

    $fp = fopen($url,'r') or die("can't open file");
      while (!feof($fp)){
          $csv_array = fgetcsv($fp,4096,",");
          print_r($csv_array);
      }
    fclose($fp);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?