how to unzip .nc.gz files

I'm new to r, and I have to open more than 1000 .nc files that are compressed as .nc.gz, I don't know how to create a loop that unzips the files in that folder so that I can read them later.

Another option is to read the files without decompressing them.

thanks

1 Like

You can do something like this

library(purrr)
library(R.utils)

list_of_files <- list.files(path = "path/to/your/folder",
           pattern = "\\.gz$",
           full.names = TRUE)

list_of_files %>% 
    walk(gunzip)
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.