# Convert NetCDF to CSV

**URL:** <https://forum.ecmwf.int/t/convert-netcdf-to-csv/1242>\
**Category:** Software and Tools\
**Tags:** netcdf, c3s, csv, conversion\
**Created:** [29 January 2021 12:25 UTC](https://forum.ecmwf.int/t/convert-netcdf-to-csv/1242 "2021-01-29T12:25:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gizem\_Boztas](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@Gizem\_Boztas](https://forum.ecmwf.int/u/Gizem_Boztas)\
**Post date:** [29 January 2021 12:25 UTC](https://forum.ecmwf.int/t/convert-netcdf-to-csv/1242/1 "2021-01-29T12:25:04Z")

</div>

Hello, I want to convert my netcdf file to CSV. For this, I reviewed the How to convert NetCDF to CSV page and tried the pyhton codes. But  
**time\_dim, lat\_dim, lon\_dim = tcwv.get\_dims ()**  
 in this code i get the following error.

**ValueError: too many values ​​to unpack (expected 3).**

How can I solve it, can you help me? It's really important. I also leave below how I use the codes. Thank you from now.

import cdsapi  
 import netCDF4  
 from netCDF4 import num2date  
 import numpy as np  
 import os  
 import pandas as pd  
 c = cdsapi.Client ()  
 file\_location = r "C: \ Users \ A \ Desktop \ [download.nc](http://download.nc)"

c.retrieve (  
 'reanalysis-era5-single-levels-monthly-means',  
 {  
 'product\_type': 'monthly\_averaged\_reanalysis',  
 'variable': 'total\_column\_water\_vapour',  
 'year': (  
 '2019', '2020',  
 ],  
 'month': [  
 '01', '02', '03',  
 '04', '05', '06',  
 '07', '08', '09',  
 '10', '11', '12',  
 ],  
 'time': '00: 00 ',  
 'area': (  
 41.15, 39.88, 38.94,  
 43,  
 ],  
 'format': 'netcdf',  
 },  
 file\_location)  
 f = netCDF4.Dataset (file\_location)  
 tcwv = f.variables ('tcwv')  
 time\_dim, lat\_dim, lon\_dim = tcwv.get\_dims ()  
 time\_var = f.variables [[time\_dim.name](http://time_dim.name)]  
 times = num2date (time\_var [:], time\_var.units)  
 latitudes = f.variables [[lat\_dim.name](http://lat_dim.name)] [:]  
 longitudes = f.variables [[lon\_dim.name](http://lon_dim.name)] [:]  
 output\_dir = './'

---

<div class="post-metadata">

**Author:** ![Michela](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/m/898d66/32.png) [@Michela](https://forum.ecmwf.int/u/Michela)\
**Post date:** [11 February 2021 18:07 UTC](https://forum.ecmwf.int/t/convert-netcdf-to-csv/1242/2 "2021-02-11T18:07:00Z")

</div>

Hi,

this is probably due to the extra dimension 'expver', please have a look at the following link for details:

[ERA5 CDS requests which return a mixture of ERA5 and ERA5T data](https://confluence.ecmwf.int/pages/viewpage.action?pageId=173385064)

Thanks

Michela
