def to_unicode(x, unaccent=False):
    """Convert a string to unicode"""
    s = str(x)

    if unaccent:
        cs = [c for c in unicodedata.normalize('NFD', s)
              if unicodedata.category(c) != 'Mn']
        s = ''.join(cs)

    return s
Convert a string to unicode