How to use the csvkit.table.Column function in csvkit

To help you get started, we’ve selected a few csvkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wireservice / csvkit / tests / test_sql.py View on Github external
def test_make_column_name(self):
        c = sql.make_column(table.Column(0, 'test', [u'1', u'-87', u'418000000', u'']))
        self.assertEqual(c.key, 'test')
github wireservice / csvkit / tests / test_sql.py View on Github external
def test_column_has_nulls(self):
        c = sql.make_column(table.Column(0, 'test', [u'1', u'-87', u'418000000', u'']))
        self.assertEqual(c.key, 'test')
        self.assertEqual(type(c.type), Integer)
        self.assertEqual(c.nullable, True)
github wireservice / csvkit / tests / test_table.py View on Github external
def test_table_append_duplicate_name(self):
        c = table.Column(0, u'test', [u'test', u'column', u''])
        c2 = table.Column(0, u'test', [u'test', u'column', u''])
        c3 = table.Column(0, u'test', [u'test', u'column', u''])
        t = table.Table()
        t.append(c)
        t.append(c2)
        t.append(c3)
        self.assertEqual(t[0].name, 'test')
        self.assertEqual(t[1].name, 'test_2')
        self.assertEqual(t[2].name, 'test_3')
github wireservice / csvkit / tests / test_table.py View on Github external
def test_table_count_rows(self):
        c = table.Column(0, u'test', [u'test', u'column', u''])
        c_short = table.Column(0, u'test', [u'test'])
        c_long = table.Column(0, u'test', [u'', u'', u'', u''])
        t = table.Table()
        self.assertEqual(t.count_rows(), 0)
        t.append(c)
        self.assertEqual(t.count_rows(), 3)
        t.append(c_short)
        self.assertEqual(t.count_rows(), 3)
        t.append(c_long)
        self.assertEqual(t.count_rows(), 4)
github wireservice / csvkit / tests / test_table.py View on Github external
def test_table_extend(self):
        c = table.Column(0, u'test', [u'test', u'column', u''])
        c2 = table.Column(0, u'test', [u'test', u'column', u''])
        c3 = table.Column(0, u'test', [u'test', u'column', u''])
        t = table.Table([c])
        t.extend([c2, c3])
        self.assertEqual(len(t), 3)
        self.assertEqual(t[0], c)
        self.assertEqual(t[1], c2)
        self.assertEqual(t[2], c3)
        self.assertEqual(t[0].order, 0)
        self.assertEqual(t[1].order, 1)
        self.assertEqual(t[2].order, 2)
github wireservice / csvkit / tests / test_sql.py View on Github external
def test_make_column_null(self):
        c = sql.make_column(table.Column(0, 'test', [u'', u'', u'']))
        self.assertEqual(type(c.type), String)
github wireservice / csvkit / tests / test_sql.py View on Github external
def setUp(self):
        self.csv_table = table.Table([
            table.Column(0, u'text', [u'Chicago Reader', u'Chicago Sun-Times', u'Chicago Tribune', u'Row with blanks']),
            table.Column(1, u'integer', [u'40', u'63', u'164', u'']),
            table.Column(2, u'datetime', [u'Jan 1, 2008 at 4:40 AM', u'2010-01-27T03:45:00', u'3/1/08 16:14:45', u'']),
            table.Column(3, u'empty_column', [u'', u'', u'', u''])],
            name='test_table')
github wireservice / csvkit / tests / test_table.py View on Github external
def test_table_remove(self):
        c = table.Column(0, u'test', [u'test', u'column', u''])
        c2 = table.Column(0, u'test', [u'test', u'column', u''])
        c3 = table.Column(0, u'test', [u'test', u'column', u''])
        t = table.Table([c, c2, c3])
        t.remove(c2)
        self.assertEqual(len(t), 2)
        self.assertEqual(t[0], c)
        self.assertEqual(t[1], c3)
        self.assertEqual(t[0].order, 0)
        self.assertEqual(t[1].order, 1)