def csv(self, filename=None, **format_params):
if not self.pretty:<EOL><INDENT>return None  <EOL><DEDENT>if filename:<EOL><INDENT>outfile = open(filename, '<STR_LIT:w>')<EOL><DEDENT>else:<EOL><INDENT>outfile = StringIO()<EOL><DEDENT>writer = UnicodeWriter(outfile, **format_params)<EOL>writer.writerow(self.field_names)<EOL>for row in self:<EOL><INDENT>writer.writerow(row)<EOL><DEDENT>if filename:<EOL><INDENT>outfile.close()<EOL>return CsvResultDescriptor(filename)<EOL><DEDENT>else:<EOL><INDENT>return outfile.getvalue()<EOL><DEDENT>
Generates results in comma-separated form.  Write to ``filename``
        if given. Any other parameter will be passed on to ``csv.writer``.

        :param filename: if given, the CSV will be written to filename.

        Any additional keyword arguments will be passsed
        through to ``csv.writer``.