I have a list of content which I want to import to Plone with plone.api.create.
All fields are originally strings, so I have to convert some of them to ints and floats. The fields are not required, so this will give me a problem with 'empty fields' when creating the content ( since int("") and float("") gives errors)
IS there a way to do this without a lot of checking for 'isvalue' or similar (there are much more fields than in the example below:
>>> int(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
A better approach could be to "clean" the data before, eg:
i['weight'] = None if i['weight'].strip() == '' else int(i['weight'].strip())