使用J从安全链接读取CSV文件

问题描述 投票:3回答:1

我正在尝试从https://www.alphavantage.co/获取CSV文件并将值传递给J进行处理。

我尝试过httpget和web / gethttp(基于curl),但两个都打了一堵墙,至于httpget,我不知道如何将https传递给httpget函数。我无法让gethttp工作。

链接看起来像这样(这是一个演示链接):https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=MSFT&interval=5min&apikey=demo&datatype=csv

我用httpget试用了这个错误:

|domain error: httpget
   log    ;:^:_1 host;(":port);path

如何使用J来获取在线csv并将其传递给我的代码?谢谢。

编辑:这是我的平台

Engine: j901/j64/linux
Beta-c: commercial/2019-04-03T10:18:09
Library: 9.01.03
Qt IDE: 1.8.1/5.5.1
Platform: Linux 64
Installer: J901 install
InstallPath: /home/sam/j901
curl j
1个回答
2
投票

使用上面给出的链接,以下内容适用于Windows 10:

   load 'web/gethttp csv'
   Link=: 'https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=MSFT&interval=5min&apikey=demo&datatype=csv'
   fixcsv gethttp Link
┌───────────────────┬────────┬────────┬────────┬────────┬────────┐
│timestamp          │open    │high    │low     │close   │volume  │
├───────────────────┼────────┼────────┼────────┼────────┼────────┤
│2019-04-18 16:00:00│123.3900│123.5000│123.3000│123.3700│1327949 │
├───────────────────┼────────┼────────┼────────┼────────┼────────┤
│2019-04-18 15:55:00│123.4100│123.4800│123.3000│123.3900│931359  │
├───────────────────┼────────┼────────┼────────┼────────┼────────┤
│2019-04-18 15:50:00│123.3250│123.4200│123.2900│123.4100│340777  │
└───────────────────┴────────┴────────┴────────┴────────┴────────┘
...

      JVERSION
Engine: j807/j64/windows
Release-d: commercial/2019-03-18T13:21:35
Library: 8.07.25
Qt IDE: 1.7.9s/5.9.6
Platform: Win 64
Installer: J807 install
InstallPath: c:/program files/j64-807
Contact: www.jsoftware.com

对于Linux来说,似乎需要一组额外的双引号来使curlwget正确解释链接:

   fixcsv gethttp dquote Link
┌───────────────────┬────────┬────────┬────────┬────────┬────────┐
│timestamp          │open    │high    │low     │close   │volume  │
├───────────────────┼────────┼────────┼────────┼────────┼────────┤
│2019-04-18 16:00:00│123.3900│123.5000│123.3000│123.3700│1327949 │
├───────────────────┼────────┼────────┼────────┼────────┼────────┤
...

双引号也适用于Windows,因此您可以双引号链接,它应该可以跨平台工作。

© www.soinside.com 2019 - 2024. All rights reserved.