How to make “int” parse blank strings?

Use int() function with the argument s.strip() or 0, i.e:

int(s.strip() or 0)

Or if you know that the string will always contain only digit characters or is empty (""), then just:

int(s or 0)

In your specific case you can use lambda expression, e.g:

parse_table = [\
    ....
    ('numeric_field', lambda s: int(s.strip() or 0), 10), # int example
    ...
]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)