2👍
✅
Wrap the conversion to float in a function call.
def convert_value(val, conversion=float):
try:
return conversion(val)
except ValueError:
return None
or
report.something = float(line[x]) if line[x] is not None else None
👤John
Source:stackexchange.com