This repository contains code used to convert between files in netCDF (.nc) to Excel (.xlsx, .xls) and from Excel to netCDF. In the Excel -> netCDF direction, it is set up to convert individual sheets within a workbook to netCDF format one at a time.
This repository contains two scripts for conversion between Excel (.xlxs and .xls) and netCDF (.nc) files. They are called, ExcelToNetcdf.py and NetcdfToExcel.py, respectively. You can run them on their own or in a Docker container. The Docker container can be built via the Dockerfile in the repository, or from the image on DockerHub https://hub.docker.com/r/acryan/netcdf-excel-conversion. We give instructions below on how to pull the image from DockerHub and run the script inside a container.
- Clone the repository to your local machine and
cd
into thenetcdf-excel-conversion
folder. - Create an empty folder here called
data/
and two other folders inside it calledinput/
andoutput/
. - Copy all files to be converted into the
data/input/
folder. These files should be Excel and/or netCDF files. Leavedata/output/
empty for now.
cd
into the root directory of this repository on your local machine. Remember: You must have added the three folders described above and copied your files for conversion into thedata/input/
folder.- In the root directory, start the Docker container:
docker run -it -v $(pwd):/work acryan/netcdf-excel-conversion /bin/bash
(you will end up with a bash prompt inside the container) - Go to the directory that contains the python script:
cd /work
- Run the python script:
python ExcelToNetcdf.py
. Each time you convert a file, you will be prompted to input the name of the original file. In the case of converting Excel files, you will also need to input the name of the individual sheet to be converted. - To exit the container, run
exit
All converted files will be written to the data/output
folder you created in Step 1.