R Under development (unstable) (2024-03-11 r86098 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(DatastreamR) > > # Login using Configuration > timeseriesClient = TimeSeriesClient$new('Config.ini') INFO [2024-03-13 10:17:40] DSConnect.R DSConnect$getToken :Getting Token and Token Expiry INFO [2024-03-13 10:17:40] DSConnect.R DSConnect$getJsonResponse Web response received > > if (!is.null(timeseriesClient) & timeseriesClient$IsValid()) + { + tryCatch({ + print('Requesting all timeseries available for your + datastream ID.') + itemsResp = timeseriesClient$GetAllItems() + + + if (!is.null(itemsResp)) + { + if (itemsResp$ResponseStatus != + DSUserObjectResponseStatus$UserObjectSuccess) + { + print(paste('GetAllItems failed with error', + names(DSUserObjectResponseStatus)[itemsResp$ResponseStatus+1], + itemsResp$ErrorMessage)) + } + else if ((is.null(itemsResp$UserObjects)) | (itemsResp$UserObjectsCount == 0)) + print(paste('GetAllItems returned zero timeseries items.', '\n\n')) + else + { + print(paste('GetAllItems returned ', + itemsResp$UserObjectsCount, + ' timeseries items.')) + colnames = c('Id','LastModified', 'startDate', + 'endDate','Frequency', 'NoOfValues', + 'Desc') + df = data.frame() + + for (tsItem in itemsResp$UserObjects) + { + coldata = NULL + if (!is.null(tsItem)) + { + rowdata = c (Id = tsItem$Id, + Desc = tsItem$Description, + LastModified = as.character(tsItem$LastModified), + StartDate = ifelse (!is.null(tsItem$DateInfo), as.character(tsItem$DateInfo$StartDate), NULL), + EndDate = ifelse(!is.null(tsItem$DateInfo),as.character(tsItem$DateInfo$EndDate), NULL), + Frequency = ifelse(!is.null(tsItem$DateInfo), tsItem$DateInfo$Frequency, NULL), + NoOfValues = ifelse(!is.null(tsItem$DateRange), tsItem$DateRange$ValuesCount , 0)) + df = rbind(df, rowdata) + } + } + colnames(df) = colnames + print(df) + } + } + }, + error = function(e) + { + print(paste('TimeseriesClient request failed with error message:', message(e))) + stop(message(e)) + }) + } [1] "Requesting all timeseries available for your\n datastream ID." INFO [2024-03-13 10:17:40] DatastreamUserCreated_TimeSeries.R TimeseriesClient$GetAllItems GetAllItems requested INFO [2024-03-13 10:17:40] DSConnect.R DSConnect$getJsonResponse Web response received INFO [2024-03-13 10:17:41] DatastreamUserCreated_TimeSeries.R TimeSeriesClient$GetAllItems GetAllItems returned [1] "GetAllItems returned 25 timeseries items." Id LastModified startDate 1 TS000001 Cross-section average of OECD countries inflation 2023-03-01 2 TS00000A JohnS testing frequency conversion actual 2024-02-08 3 TS0001JS TS0001JS 2022-08-08 4 TSABCPKK TSABC.PK 2020-10-12 5 TSBETA13 JOHN LOWERCASE 2019-04-12 6 TSDAYS03 SP500 number of days outside small gains fixed up 2023-03-02 7 TSJS0001 TSJS0001 2014-06-30 8 TSTEST04 JS4 2017-01-03 9 TSTEST06 TS06 2017-01-03 10 TSTEST07 JS07 2017-01-03 11 TSTEST99 TSTEST99 2020-10-15 12 TSTR6000 2 2020-11-20 13 TSUSA831 TSUSA831 2020-04-28 14 TSVDV021 TSVDV021 2023-01-13 15 TSVDVD04 TSVDVD04 2022-02-01 16 TSVDVD18 TSVDVD18 2023-01-09 17 TSVID022 VID 2020-11-12 18 TSVID830 TSVID830 2020-04-28 19 TSVV0001 My Test series : TSVV0001 2022-03-25 20 TSVVV001 My first test timeseries 2023-02-08 21 TSVVV002 TSVVV002 2022-04-12 22 TSVVV010 TSVVV010 2022-04-13 23 TSVVVD04 TSVVVD04 2022-04-12 24 TSXYZPKK Strange 16/02/20 name 2020-10-19 25 TSZZZ002 My first test timeseries 2023-06-14 endDate Frequency NoOfValues Desc 1 1980-12-15 2022-04-15 2 497 2 2023-02-01 2023-02-16 0 12 3 2016-06-30 2020-06-30 4 5 4 2010-01-31 2010-05-31 2 5 5 2019-01-01 2019-01-04 0 4 6 1964-01-02 2023-03-01 0 15435 7 2014-01-31 2014-06-27 0 106 8 2016-12-02 2016-12-30 1 5 9 2010-03-31 2016-12-31 3 28 10 2016-01-31 2016-12-31 2 12 11 2019-01-01 2019-01-04 0 4 12 2000-01-31 2002-01-31 2 25 13 2010-01-31 2010-05-31 2 5 14 2016-01-01 2016-02-05 0 26 15 2021-01-31 2021-06-30 2 6 16 2021-01-31 2021-02-08 0 7 17 1950-12-02 1950-12-29 1 5 18 2020-04-28 2020-04-28 0 1 19 2016-01-02 2016-02-01 0 22 20 2016-02-15 2022-05-15 3 26 21 2000-01-01 2000-01-05 0 4 22 2000-01-01 2000-01-20 0 15 23 2012-04-23 2012-04-26 0 4 24 2010-01-31 2010-05-31 2 5 25 2016-03-31 2022-06-30 3 26 > > > > proc.time() user system elapsed 0.89 0.18 1.21