The following line of Python code
values = ", ".join(["\"%s\"" % x for x in row])
takes a list of elements in “row” to create a comma-separated string “values”, while each value is put in double quotes, e.g.:
“New York”, “5”, “”, “3.2”
However, since the result is to be part of a mysqldump file, empty fields (“”) should become NULL (without double quotes).
Therefore, I’d like to learn how to change that expression so that it is checked whether x is empty (“”), in which case NULL should be appended to the values string.
Thanks
1 Answer