如何解析存储在AWS S3中的JSON文件/ JSON流?

时间:2019-02-27 08:09:18

标签: r json parsing amazon-s3 stream

我有一个装满JSON文件或带有多个JSON(流)文件的AWS S3存储桶。

我的目标是在R Studio中进行连接和解析。

这是我已经做的:

bl <- bucketlist()

# Builds a dataframe of the files metadata in a bucket:

dfBucket <- get_bucket(bucket = "company-kuku-streamed-data", prefix = "2019/", max = Inf) %>% 
  rbindlist()

# Create path based on data in bucket:

path <- dfBucket$Key

get_bucket_files <- function(path, bucket_prefix = 's3://company-kuku-streamed-data/') {

  url <- paste0(bucket_prefix, path)
  s3Vector <- get_object(url)
  s3Value <- rawToChar(s3Vector)
  return(s3Value)

}

并使用以上内容:

plan(strategy = "multicore")

ingenico_json_files_list <- furrr::future_map(path, get_bucket_files)

当我尝试解析文件时,对于包含多个JSON作为文件流的文件,我得到一个错误。

请告知如何在不使用正则表达式手动修复和分离的情况下阅读全部内容? 我觉得必须有知道这种情况的职能。

0 个答案:

没有答案