'Extract variables from multiple NetCDF files stored in multiple folders

I am trying to extract some variables from different netCDF files stored in different folders and save them in a CSV file.

Until now I'm trying to extract the needed variables from one file at a time, as follows:

    f1 = nc.Dataset('...')
    f2 = nc.Dataset('...')
    f3 = nc.Dataset('...')

and then:

lat1 = f1.variables['lat_l1b_echo_sar_ku'][:]  
lon1 = f1.variables['lon_l1b_echo_sar_ku'][:]
tim1 = f1.variables['time_l1b_echo_sar_ku'][:]
wav1 = f1.variables['i2q2_meas_ku_l1b_echo_sar_ku'][:]

Can anyone help me to batch this process?

Any help would be much appreciated.

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source