我正在使用气候数据运算符从 NetCDF 中提取时间序列数据。它可以选择单独提取日期和时间。我用过
cdo -outputtab,date,time,value -remapnn,lon=-85.25_lat=31.57 -select,name=pr pr.sample.nc> out1.csv
但是,我想将这个日期和时间合并到一个列中。
这是我的输入.csv
https://drive.google.com/drive/folders/1C7XWGXafu1coNICK55AA-GzdM9DqnbuA?usp=sharing
答案1
如果是 CSV:
你可以使用awk
,如果有效的话试试这个:
awk 'FNR==1{ row=$2","$3$4","$5;print row } FNR!=1{ row=$1","$2$3","$4; print row}' input.csv
答案2
如果您的输入文件是链接的,则它不是csv
空格分隔的
# name date time value
pr 2006-01-01 12:00:00 0.002509068
pr 2006-01-02 12:00:00 0.8440843
pr 2006-01-03 12:00:00 0.3695453
pr 2006-01-04 12:00:00 6.589583
pr 2006-01-05 12:00:00 16.20289
pr 2006-01-06 12:00:00 0.1449011
pr 2006-01-07 12:00:00 29.98764
pr 2006-01-08 12:00:00 18.44757
和
awk 'BEGIN{OFS=","}
NR==1{print $2,$3"-"$4,$5}
NR>1{split($2,d,"-");print $1, int(d[2])"/"d[3]"/"d[1]$3, $4}' input.csv
会给你
name,date-time,value
pr,1/01/200612:00:00,0.002509068
pr,1/02/200612:00:00,0.8440843
pr,1/03/200612:00:00,0.3695453
pr,1/04/200612:00:00,6.589583
pr,1/05/200612:00:00,16.20289
pr,1/06/200612:00:00,0.1449011
pr,1/07/200612:00:00,29.98764
pr,1/08/200612:00:00,18.44757
split
并根据日期重新组合png
当重定向到> out.csv
此时,将按照以下方式在单独的列中打开png