代码之家  ›  专栏  ›  技术社区  ›  Dante

跳过zip文件中的空文件

r
  •  0
  • Dante  · 技术社区  · 6 年前

    .csv 文件位于 .zip

    for (i in unzip("data.zip", list = TRUE)) {
        read.csv(unz("data.zip", i))
    }
    

    文件为空,导致 no lines available in input

    0 回复  |  直到 6 年前
        1
  •  1
  •   dcarlson    6 年前

    试试这个

    flist <- unzip("data.zip", list=TRUE)
    

    keep <- flist$Length > 100  # or some other value that indicates the file has no data
    

    AllFiles <- lapply(flist$Name[keep], read.csv)