mixcoatl/utils.py
def to_csv(data):
    """Formats a list of dictionaries into a CSV

    :param data: a list of dictionaries
    :returns str: a str formatted in csv

    .. warning::

        A python dictionary object can't be fully represented in in csv form. Hence, the result returned will
        contain cells that have a text representation of a sub elements.
    """
    csv = ""
    for i in data[0].keys():
        csv += '"'+i.replace('"','\"')+'"'+","
    csv = csv.rstrip(",")

    for x in data:
        csv += "\n"
        for i in x:
            if isinstance(x[i], dict):
                if x[i]:
                    csv += '"'+str(x[i][x[i].keys()[0]]).replace('"','\"')+'"'+","
                else:
                    csv += '"",'
            else:
                csv += '"'+str(x[i]).replace('"','\"')+'"'+","
        csv = csv.rstrip(",")

    return csv
Formats a list of dictionaries into a CSV

    :param data: a list of dictionaries
    :returns str: a str formatted in csv

    .. warning::

        A python dictionary object can't be fully represented in in csv form. Hence, the result returned will
        contain cells that have a text representation of a sub elements.
    
Formats a list of dictionaries into a CSV
Formats a list of dictionaries into a CSV
def to_csv(data):
    csv = ""
    for i in data[0].keys():
        csv += '"'+i.replace('"','\"')+'"'+","
    csv = csv.rstrip(",")
    for x in data:
        csv += "\n"
        for i in x:
            if isinstance(x[i], dict):
                if x[i]:
                    csv += '"'+str(x[i][x[i].keys()[0]]).replace('"','\"')+'"'+","
                else:
                    csv += '"",'
            else:
                csv += '"'+str(x[i]).replace('"','\"')+'"'+","
        csv = csv.rstrip(",")
    return csv
def to_csv ( data ) : csv = "" for i in data [ 0 ] . keys ( ) : csv += '"' + i . replace ( '"' , '\"' ) + '"' + "," csv = csv . rstrip ( "," ) for x in data : csv += "\n" for i in x : if isinstance ( x [ i ] , dict ) : if x [ i ] : csv += '"' + str ( x [ i ] [ x [ i ] . keys ( ) [ 0 ] ] ) . replace ( '"' , '\"' ) + '"' + "," else : csv += '"",' else : csv += '"' + str ( x [ i ] ) . replace ( '"' , '\"' ) + '"' + "," csv = csv . rstrip ( "," ) return csv
Formats a list of dictionaries into a CSV
Formats a list of dictionaries into a CSV
"""Formats a list of dictionaries into a CSV

    :param data: a list of dictionaries
    :returns str: a str formatted in csv

    .. warning::

        A python dictionary object can't be fully represented in in csv form. Hence, the result returned will
        contain cells that have a text representation of a sub elements.
    """
a str formatted in csv
warning:.

A python dictionary object can't be fully represented in in csv form. Hence, the result returned will
contain cells that have a text representation of a sub elements.
a str formatted in csv warning : . A python dictionary object can ' t be fully represented in in csv form . Hence the result returned will contain cells that have a text representation of a sub elements .
str
data
a list of dictionaries
a list of dictionaries