How do I retrieve data using a Quandl connection when the Quandl database provides tables instead of time series data

5 ビュー (過去 30 日間)
How do I retrieve data using a Quandl connection when the Quandl database provides tables instead of time series data
Quandl has databases. Each database has several securities.
Some databases implement the Tables API while others implement the Time series API.
Depending on what API they implement, the securities in that database will either output timeseries data or table data(not the MATLAB datatype but json)
I am able to successfully read data from securities that provide time series data but not from the ones that give out table data(not the MATLAB datatype but json)
Error message seen from the resulting response object:
code: 'QECx02'
message: 'You have submitted an incorrect Quandl code. Please check your Quandl codes and try again.'

採用された回答

MathWorks Support Team
MathWorks Support Team 2020 年 9 月 14 日
The Quandl API uses a different endpoint for handling the databases implementing the Tables API.
You can execute the following commands to retrieve data that is provided by Quandl as a Table:
>> q = quand("API_KEY");
>> q.URL = "https://www.quandl.com/api/v3/datatables"; % Note that the default URL is "https://www.quandl.com/api/v3/datasets" and you will
% need to reset it if they want to request a dataset
>> data = history(q,"SHARADAR/SF1")
Unfortunately, in the case of datatables, the code is not processing the returned result(of the history function) into a MATLAB table. You can get the first record, for example, of the data with:
>> data.Body.Data.datatable.data{1}
In this case, there are 10,000 records being returned.
The following code snippet will convert the response from the 'history' function into a table in MATLAB:
>> numRecords = length(data.Body.Data.datatable.data);
>> output = cell(numRecords,length(data.Body.Data.datatable.columns));
>> for i = 1:numRecords
>> output(i,:) = data.Body.Data.datatable.data{i};
>> end
>> outputTable = cell2table(output,'variablenames',{data.Body.Data.datatable.columns.name});

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by