R Under development (unstable) (2024-03-14 r86117 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-14 15:45:59] DSConnect.R DSConnect$getToken :Getting Token and Token Expiry could not find function "content_type_json"ERROR [2024-03-14 15:45:59] DSConnect.R DSConnect$getToken could not find function "content_type_json"ERROR [2024-03-14 15:45:59] DSConnect.R DSConnect$getToken No 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)) + }) + } > > > > proc.time() user system elapsed 0.46 0.18 0.60