Skip to content

ncconvert#

main codecov

tsdat/ncconvert is a tool that helps convert netCDF files to other formats.

Installation#

pip install "ncconvert[cli]"

Tip

The [cli] part is an optional specifier configured in ncconvert that tells pip that we also want to install typer and other dependencies to support command-line usage of ncconvert.

Usage#

ncconvert to_csv path/to/your/data/*.nc --output-dir path/to/output/folder/ --verbose

Format supported other than csv is parquet. To see more information about supported formats, run

ncconvert --help

A python API is also available for each format, e.g.:

import xarray as xr 
from ncconvert import to_csv 

ds = xr.open_dataset("path/to/your/netcdf-file.nc") 

to_csv(ds, "path/to/output/folder/filename.csv") 
import xarray as xr
from ncconvert import to_csv_collection

ds = xr.open_dataset("netcdf-file.nc")

# Define the file path where CSV files will be stored
file_path = "path/to/your/output/file"

# Call the to_csv_collection function
csv_files, metadata_file = to_csv_collection(dataset, file_path)