from io import StringIO
import csv


def make_csv(data):
    """Create a CSV string from an array of dictionaries"""
    if type(data) == str:
        return data
    buf = StringIO()
    writer = csv.DictWriter(buf, data[0].keys())
    writer.writeheader()
    for row in data:
        writer.writerow(row)
    r = buf.getvalue()
    buf.close()
    return r