从URL导入数据 [英] Import data from URL

查看:229
本文介绍了从URL导入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

圣路易斯联邦储备银行在其各种网页上都有大量可用的数据,例如:

The St. Louis Federal Reserve Bank has a great set of data available on a variety of their web pages, such as:

http://research.stlouisfed.org/fred2/series/OILPRICE/downloaddata?cid = 32217 http://www.federalreserve.gov/releases/h10/summary/default.htm http://research.stlouisfed.org/fred2/series/DGS20

数据集会每天更新一次.我倾向于对日常数据感兴趣(请参阅URLS上的上述设置)

The data sets get updated, some as often as daily. I tend to have an interest in the daily data (see the above settings on the URLS)

我想将这类价格或费率数据流(可通过上述URL在CSV或Excel文件中访问)直接导入Mathematica.

I'd like to import these kinds of price or rate data streams (accessible as CSV or Excel files at the above URLs) directly into Mathematica.

我看过有关Importing []的文档,但是我发现很少有文档(实际上没有)有关如何进行此类操作.

I've looked at the documentation on Importing[] but I find scant documentation (actually none) on how to go about something like this.

看起来我需要导航至页面,发送一些数据以选择特定的文件和格式,触发下载,然后从我自己的计算机访问下载的数据.如果我可以直接从站点访问数据,那就更好了.

It looks like I need to navigate to the pages, send some data to select specific files and formats, trigger the download, then access the downloaded data from my own machine. Even better if I could access the data directly from the sites.

我曾希望Wolfram Alpha可以使这种事情变得容易,但是我没有取得任何成功.

I had hoped Wolfram Alpha might make this sort thing easy, but I haven't had any success.

FinancialData[]对于这种事情似乎很自然,但是我仍然看不到要这样做.财务数据具有很多功能,但是我看不到这种方式.

FinancialData[] would seem natural for this sort of thing, but I don't see anyway to do it. Financial data has lots of features, but I don't see a way yo get this sort of thing.

有人对此有任何经验吗?有人可以向我指出正确的方向吗?

Does anyone have any experience with this or can someone point me in the right direction?

推荐答案

您可以直接从URL Import.例如,可以从以下位置获取并可视化来自Federalreserve.gov的数据.

You can Import directly from a URL. For example, the data from federalreserve.gov can be obtained and visualized as follows.

url = "http://www.federalreserve.gov/datadownload/Output.aspx?";
url = url<>"rel=H10&series=a660e724c705cea4b7bd1d1b85789862&lastObs=&";
url = url<>"from=&to=&filetype=csv&label=include&layout=seriescolumn";
data = Import[url, "CSV"];
DateListPlot[data[[7 ;;]], Joined -> True]

为了方便起见,我分手了url,因为它很长.在我确切地知道如何绘制data的内容之前,我必须检查它的内容-这是通常必需的步骤.我确信可以以类似的方式从stlouisfed.org获取数据,但是它需要使用带有密钥的API来访问它.

I broke up url for convenience, since it's so long. I had to examine the contents of data before I knew exactly how to plot it - a step that is typically necessary. I'm sure that the data from stlouisfed.org can be obtained in a similar way, but it requires the use of an API with key to access it.

这篇关于从URL导入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆