Convert Multiple NetCDF files into CSVs

Jun 3, 2011 at 5:30 PM


I have multiple NetCDF files that I want to convert to CSV files.  Is it possible to do this from C#?  I'd like to simply specify the source file folder and the destination file folders.

Thanks much...



Jun 3, 2011 at 7:34 PM

Hi Marilyn,

The simplest way to do that is to do the following:

1. Open command window from the folder containing NetCDF files (if you need instructions, take a look here).

2. Type the command:


forfiles /m *.nc /c "cmd /c sds copy @file c:\temp\outdir\\@fname.csv?openMode=create"

You can replace c:\temp\outdir with the real path to folder where you want to collect CSV files (note that there must two slashes before @fname to be parsed properly, otherwise one slash ('\@') would escape the reserved symbol '@').

More information about forfiles command is here.





Jun 3, 2011 at 7:42 PM

Sorry, just noticed that you need to convert files from C#. 

That's very simple, too. Just use foreach statement to enumerate files from the given folder; use System.IO.Directory class for that:

Directory.EnumerateFiles(@"c:\temp\library\", "*.nc")

And for each file use such code:

DataSet.Open(filePath).Clone(Path.Combine(outputDir, Path.GetFileName(filePath) + ".csv") + "?openMode=create").Dispose();

Jun 3, 2011 at 7:44 PM

Thank you very much for your reply.  I'll work on this and let you know if I encounter anything.


Jun 3, 2011 at 7:51 PM


Works perfectly!!!  Thank you so much,