Reputation: 47
I'm trying to get a single csv file from several thousand netcdf files where each file represents a single point in time. The files contain time, latitude, longitude, and 4 different weather variables. My thought process is to merge the files into one netcdf file and then I can write a csv file from that but I'm not sure how to merge 29000 files with a simple code without having to write the name of the files over and over.
Upvotes: 2
Views: 339
Reputation: 2078
Use netCDF operators. Either cdo
or nco
.
To merge your files in time with cdo
, just:
cdo mergetime input_files output_file
and with using nco (according to https://linux.die.net/man/1/ncrcat):
ncrcat input_files outputfile
You can specify input_files
with wildcard *
. Basically, if your thousands of files are named like: file_000001.nc,file_000002.nc,...,file_vwxyz.nc, do:
cdo mergetime file_* files.nc
Other way is just to loop over the file names and do all your operations with r or whatever tool that you are using. Nevertheless, cdo or nco, are the right tools for your problem.
Upvotes: 1