Mercurial > hg > numerics
annotate numerics/csvwriter.py @ 164:c16940bd2cee
this works
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 15 May 2015 16:59:09 -0700 |
parents | 7927d7127f9a |
children |
rev | line source |
---|---|
44 | 1 #!/usr/bin/env python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 import csv | |
5 string = (str, unicode) | |
6 __all__ = ['CSVWriter'] | |
7 | |
8 class CSVWriter(object): | |
9 """a more sensible front-end to writing CSV files""" | |
10 | |
11 def __init__(self, f, mode='a'): | |
12 if isinstance(f, string): | |
13 f = open(f, mode) | |
14 self.f = f | |
15 self.writer = csv.writer(f) | |
16 | |
17 def __call__(self, *data): | |
18 self.writer.writerow(data) | |
19 self.f.flush() |