Project

General

Profile

change history with setattribute

Added by S BR over 4 years ago

Hi All,
I want to replace the contents of history (global attributes) with a text paragraph contains 2-3 lines, using 'setattribute'. Is it possible?

As per the user document (cdo setattribute,my_att="my contents" infile outfile), I tried the following short example

cdo setattribute,history="Department, University" infile outfile

In the outfile, I can only see 'Department' but not 'Department, University'.
I think it is due to the use of comma (,).Any solution?

Thank you.


Replies (5)

RE: change history with setattribute - Added by Karin Meier-Fleischer over 4 years ago

Hi S,

I can reproduce the problem and I would use NCO's ncatted instead

ncatted -O -a history,global,a,c,"Department, University\n" infile outfile

-Karin

RE: change history with setattribute - Added by S BR over 4 years ago

Hi Karin,
Thank you. It just appending an extra line to history.
It should freshly write the given sentence by deleting the existing contents in the 'history'.

S

RE: change history with setattribute - Added by Karin Meier-Fleischer over 4 years ago

That's why it is called 'History'.

ncatted -h -O -a history,global,o,c,"Department, University\n" test_1.nc out.nc

RE: change history with setattribute - Added by S BR over 4 years ago

Hi Karin,
I could solve this with some modification.
ncatted -O -h -a history,global,o,c,'Department, University' infile outfile

RE: change history with setattribute - Added by Uwe Schulzweida about 4 years ago

The next CDO release 1.9.9 will allow commas in attributes!

    (1-5/5)