I want to load a file from Azur cloud storage named "file_last_dates.rds". The original function used was readRDS, and I'm changing it to storage_load_rds. The latter function is not returning the same thing as readRDS.
This is the output that I want:
> readRDS("/home/.../file_last_dates.rds")
$`st_rfe.mli.{year}_dek.sf.rds`
[1] "2022-12-31"
$`st_rfe.mli.{year}_day.sf.rds`
[1] "2022-12-31"
But this is the output that I'm getting:
> storage_load_rds(cont,"file_last_dates.rds")
[[1]]
[[1]]$`st_rfe.mli.{year}_dek.sf.rds`
[1] "2022-12-31"
[[1]]$`st_rfe.mli.{year}_day.sf.rds`
[1] "2022-12-31"
How do I fix the second output so that it looks like the first output? Thanks.
How do I fix the second output so that it looks like the first output
I agree with @r2evans comment , you can use the storage_load_rds(cont,"file_last_dates.rds")[[1]]
to get the required format as same readRDS.
I tried with the below r code and it executed successfully.
Code:
library(AzureStor)
# Define Azure Blob Storage credentials
account_endpoint <- "https://venkat123.blob.core.windows.net"
storage_account_key <- "your account key"
container_name <- "test"
bl_endp_key <- storage_endpoint(account_endpoint, key=storage_account_key)
cont <- storage_container(bl_endp_key, container_name)
# Load the RDS file from Azure Blob Storage
file_last_dates <- storage_load_rds(cont, "file_last_dates.rds")[[1]]
# Print the contents of the RDS file
print(file_last_dates)
Output:
$`st_rfe.mli.{year}_dek.sf.rds`
[1] "2022-12-31"
$`st_rfe.mli.{year}_day.sf.rds`
[1] "2022-12-31"