def csv_dict_writer(f, fieldnames, **kwargs):
    """Equivalent of csv.DictWriter, but allows `delimiter` to be a unicode string on Py2."""
    import csv
    if 'delimiter' in kwargs:
        kwargs['delimiter'] = str(kwargs['delimiter'])
    return csv.DictWriter(f, fieldnames, **kwargs)
