Separate column for each variables in csv file.
Added by ibomcha meitei over 4 years ago
Hello Everyone,
I am using codex NetCDF data for the extraction of time-series data.
I used cdo -outputtab,date,lon,lat,value -remapnn,lon={}_lat={} input.nc> output.csv for extraction for a given lon and lat value.
Here my output.csv files come with variables "date, lon, lat and value" in a single column as attached.
How can I have a separate column for each variable?
Thanks
Replies (3)
RE: Separate column for each variables in csv file. - Added by Karin Meier-Fleischer over 4 years ago
Hi Bijoy,
the output is exactly what I would expect.
# date lat lon value 1950-01-01 31.57 -85.25 0.0305868 1950-01-01 31.57 -85.25 0.03933538 1950-01-01 31.57 -85.25 0.03950347 1950-01-01 31.57 -85.25 0.03850033 1950-01-01 31.57 -85.25 0.0363825 1950-01-01 31.57 -85.25 0.03502262 1950-01-01 31.57 -85.25 0.03346673 1950-01-01 31.57 -85.25 0.03049384 1950-01-01 31.57 -85.25 0.0211379
You can write a script that reads the individual variables from the CSV file and then writes them to a new file according to your format request.
But then you have to use the name parameter with outputtab, too.
cdo -outputtab,name,date,lon,lat,value -remapnn,lon={5.0}_lat={10.0} -select,name=rhumidity,var3,t rectilinear_grid_3D.nc > out.csv
Example output:
# name date lon lat value rhumidity 2001-01-01 5 10 0.5367422 rhumidity 2001-01-02 5 10 0.3914891 rhumidity 2001-01-03 5 10 0.5083991 var3 2001-01-01 5 10 5.736573 var3 2001-01-02 5 10 10.83926 var3 2001-01-03 5 10 4.410503 t 2001-01-01 5 10 295.223 t 2001-01-02 5 10 294.6711 t 2001-01-03 5 10 232.0437
-Karin
RE: Separate column for each variables in csv file. - Added by ibomcha meitei over 4 years ago
Thanks, Karin for your reply.
However, still I got a single column which I want to have different columns for each variable.
I have usedcdo -outputtab,name,date,value -remapnn,lon=-85.25_lat=31.57 -select,name=pr pr.sample.nc> out1.csv
.
In addition, is this possible to show both date and time in a single column? So, my expected outcome looks like
@ |name | Date-Time | value |
|pr |01/01/200612:00:00 | 0.002509068 |
|pr |01/02/200612:00:00 | 0.8440843 |
|pr 01/03/200612:00:00 | 0.3695453 |
@
pr.sample.nc (37.3 MB) pr.sample.nc | |||
expected_output.csv (284 Bytes) expected_output.csv |
RE: Separate column for each variables in csv file. - Added by Karin Meier-Fleischer over 4 years ago
No, sorry. The output of each parameter is seperated by a blank.
But you can solve this with a script by combining the date and time columns and saving them in a new output file.