Closed JoshM94 closed 3 years ago
The following code works for me
u = unisens.Unisens('example1')
c = unisens.CustomAttributes(key='ecg_hy_inactive', value=101.0)
u.add_entry(c)
u.save()
If you do not want to overwrite the existing customAttributes, you need to access the already existing one and add it to there, else it will be overwritten. You can also access attributes with generic Python syntax
u = unisens.Unisens('z:/example1')
c = unisens.CustomAttributes(key='key1', value='value1')
u.add_entry(c)
u.save()
u = unisens.Unisens('z:/example1')
u.customAttributes.key2 = 'value2' # uses generic Python syntax
u.save()
u = unisens.Unisens('z:/example1')
print(u.customAttributes)
#<customAttributes({'key1': 'value1', 'key2': 'value2'})>
I'm not sure if this is what you meant. But this worked great for me. Only the new parameter is added, the old parameters still exist in the unisens file.
u = Unisens('C:/Users/Josua/Desktop/example1')
value = 100
u.CustomAttributes.new_key = value
u.save()
perfect, so it solved your problem?
Yes, thanks for your help.
Hi, I want to add a new custom attribute with one key & one value as result in unisens. I tried different code. The following overwrites all custom attributes and adds only the new one.
I also tried other code with MiscEntry as Input of add_entry
There I get an error --> AttributeError: 'MiscEntry' object has no attribute 'key'
Can you explain me the correct code to adding new custom attributes by keeping the old custom attributes?
Thanks, Josua