Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 5f31236cc8
Fetching contributors…

Cannot retrieve contributors at this time

file 22 lines (19 sloc) 0.869 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/usr/bin/env python
# coding: utf-8
# title = Exporting to a CSV File
# output = 'my-data.csv', 'my-data.dsv'
#Using plugins we can import and export ``Table`` data to CSV (really, to and
#from a lot of formats). Let's create a simple table and export it to a CSV
#file.
#You can also create any kind of DSV (delimiter-separeted value) files, just
#passing ``delimiter``, ``quote_char`` and ``line_terminator`` to ``write`` (the
#same parameters apply to ``read``).

from outputty import Table

my_table = Table(headers=['First name', 'Last name'])
my_table.append({'First name': 'Álvaro', 'Last name': 'Justen'})
my_table.append(('Flávio', 'Amieiro'))
my_table.append(['Flávio', 'Coelho'])
my_table.write('csv', 'my-data.csv')

#Let's create a other kind of DSV:
my_table.write('csv', 'my-data.dsv', delimiter=';', quote_char="'",
        line_terminator='\r\n')
Something went wrong with that request. Please try again.