首页 > 解决方案 > 需要使用 Purrr::map_dfc 传递数据文件

问题描述

我的代码对我的 90% 的 H5 文件都非常有效。但是,我有 200 多个文件中有 3 个文件有一列数据和一个额外的条目,而不是 3212,它有 3213。我不能进入并删除文件中的这些。我只需要完全忽略该特定文件或删除额外的条目。你已经尝试过 pmap 和 map2 没有成功。它循环超过 5 个文件,然后将它们全部打开到一个数据帧中。我尝试过使用可能(),但什么也没做。我不确定如何使用 tryCatch

i<- 0
      for(i in seq_along(files)) {
        name <- paste0("file_", i) 
       assign(name,files[[i]]) 


      } 

 H5_files<-lapply(files, H5Fopen)

file_list <- h5ls(H5_files[[1]])
TM_AU<- purrr::map2(H5_files, "/Diagnostics/TM_AU",  h5read)
  units <- purrr::map_char(TM_AU, "Units", H5Fopen)
  # time is contructed from the dt and t0 variables. So that the shots line up for comparison it must only be called once. 

  possible_length <-possibly(H5Fopen, otherwise= NA)
  TM_AU_df <-purrr::map_dfc(TM_AU, "Data", H5Fopen, possible_length) # I get the argument length here 
# Error: Argument 3 must be length 3312, not 3313 
  dt <-purrr::map_dbl(TM_AU, "dt", H5Fopen)
  t0 <-purrr::map_dbl(TM_AU, "t0", H5Fopen)

标签: rhdf5purrr

解决方案


推荐阅读