[Answered ]-Django reading uploaded CSV file with some empty fields

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

Leave a comment