diff --git a/pytools/__init__.py b/pytools/__init__.py index 394bb8730b45b6ce86e4a5c44473081083cc8bea..90103e0c396e3a7b1946dadb6a5fee2a8cef87df 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -1561,6 +1561,18 @@ class Table: return "\n".join(lines) + def csv(self): + """Returns a string containing a CSV representation of the table.""" + import csv + import io + + output = io.StringIO() + writer = csv.writer(output) + writer.writerows(self.rows) + + return output.getvalue().rstrip('\n') + + def latex(self, skip_lines=0, hline_after=None): if hline_after is None: hline_after = []