def encode_csv_string(str):
    """ Encode a string to be used in CSV file.

    Args:
        str:  String to encode
    Returns:
        Encoded string, including starting and ending double quote
    """
    res = ['"']
    for c in str:
        res.append(c)
        if c == '"':
            res.append('"')
    res.append('"')
    return ''.join(res)