예제 #1
0
def export_csv_tuples(filename, tuples, header=None, dialect=None):
    if not dialect: dialect = get_dialect(filename)
    with io.open(filename, 'wt', newline='', encoding=dialect.encoding) as f:
        with csv.writer(f, dialect=dialect) as csv_out:
            if header: csv_out.writerow(header)
            for t in tuples:
                csv_out.writerow(t)
예제 #2
0
def export_csv_tuples(filename, tuples, header=None, dialect=None):
    if not dialect: dialect = get_dialect(filename)
    with io.open(filename, 'wt', newline='', encoding=dialect.encoding) as f:
        with csv.writer(f, dialect=dialect) as csv_out:
            if header: csv_out.writerow(header)
            for t in tuples:
                csv_out.writerow(t)
예제 #3
0
def export_csv_tuples_iter(filename, header=None, dialect=None, append=False):
    if not dialect: dialect = get_dialect(filename)
    closefd = filename != '-'
    if filename == '-': filename = sys.stdout.fileno()
    rows = yield
    with io.open(filename, 'at' if append else 'wt', newline='', encoding=dialect.encoding, closefd=closefd) as f:
        with csv.writer(f, dialect=dialect) as csv_out:
            while True:
                csv_out.writerows(rows)
                rows = yield
예제 #4
0
def export_csv_tuples_iter(filename, header=None, dialect=None, append=False):
    if not dialect: dialect = get_dialect(filename)
    closefd = filename != '-'
    if filename == '-': filename = sys.stdout.fileno()
    rows = yield
    with io.open(filename,
                 'at' if append else 'wt',
                 newline='',
                 encoding=dialect.encoding,
                 closefd=closefd) as f:
        with csv.writer(f, dialect=dialect) as csv_out:
            while True:
                csv_out.writerows(rows)
                rows = yield