<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_csv(objects, filename, digits=5, warnings=True):
 """ Export the flatten indicators of one or several users to CSV. Parameters objects : list List of objects to be exported. filename : string File to export to. digits : int Precision of floats. Examples -------- This function can be used to export the results of :meth`bandicoot.utils.all`. If you only have one object, you can simply pass it as argument: """


    if not isinstance(objects, list):
        objects = [objects]

    data = [flatten(obj) for obj in objects]
    all_keys = [d for datum in data for d in datum.keys()]
    field_names = sorted(set(all_keys), key=lambda x: all_keys.index(x))

    with open(filename, 'w') as f:
        w = csv.writer(f)
        w.writerow(field_names)

        def make_repr(item):
            if item is None:
                return None
            elif isinstance(item, float):
                return repr(round(item, digits))
            else:
                return str(item)

        for row in data:
            row = dict((k, make_repr(v)) for k, v in row.items())
            w.writerow([make_repr(row.get(k, None)) for k in field_names])

    if warnings:
        print("Successfully exported {} object(s) to {}".format(len(objects),
              filename))