def encode_value(value, col_sep, encl='"'):
    """ convert a value to string and enclose with `encl`
        if it contains ','
    """
    if not isinstance(value, str):
        value = str(value)

    if col_sep in value:
        value = '{encl}{value}{encl}'.format(encl=encl, value=value)

    return value