I have a XML file which I want to serve as the base for a netCDF file. I am ok with reading the XML file and creating the netCDF file, both in python.
Each group or variable in the XML file has attributes and I want to add them to the netCDF file. My problem is that I do not know the names of the attributes and this whole thing needs to be automatic.
The usual way of creating and adding an attribute in python for netCDF would be like this:
grp.attr = 'name'
<attribute name="alphabet" value="abc"/>
<attribute name="number" value="42"/>
<attribute name="version" value="ncc1701"/>
for att in list_attributes:
attr_name = att.name
attr_value = att.value
grp.attr_name = attr_value