Esempio n. 1
0
def test_typeset():

    table = (('foo', 'bar', 'baz'), ('A', 1, '2'), ('B', u'2', '3.4'),
             (u'B', u'3', '7.8', True), ('D', u'xyz', 9.0), ('E', 42))

    actual = typeset(table, 'foo')
    expect = set([str, unicode])
    eq_(expect, actual)
Esempio n. 2
0
def test_typeset():

    table = (('foo', 'bar', 'baz'),
             ('A', 1, '2'),
             ('B', '2', '3.4'),
             ('B', '3', '7.8', True),
             ('D', 'xyz', 9.0),
             ('E', 42))

    actual = typeset(table, 'foo') 
    expect = set([str, str])
    eq_(expect, actual)
Esempio n. 3
0
def test_typeset():

    table = (('foo', 'bar', 'baz'),
             ('A', 1, '2'),
             ('B', u'2', '3.4'),
             (u'B', u'3', '7.8', True),
             ('D', u'xyz', 9.0),
             ('E', 42))

    actual = typeset(table, 'foo') 
    expect = {str, unicode}
    assertequal(expect, actual)
Esempio n. 4
0
    def get_column_types(self, column):
        """
        Return all of the Python types for values in a given column

        `Args:`
            column: str
                Name of the column to analyze
        `Returns:`
            list
                A list of Python types
        """

        return list(petl.typeset(self.table, column))
Esempio n. 5
0
def test_typeset():

    table = (
        ("foo", "bar", "baz"),
        ("A", 1, "2"),
        ("B", u"2", "3.4"),
        (u"B", u"3", "7.8", True),
        ("D", u"xyz", 9.0),
        ("E", 42),
    )

    actual = typeset(table, "foo")
    expect = set([str, unicode])
    eq_(expect, actual)
Esempio n. 6
0
File: misc.py Progetto: DeanWay/petl
from __future__ import division, print_function, absolute_import


# typeset()
###########

import petl as etl
table = [['foo', 'bar', 'baz'],
         ['A', 1, '2'],
         ['B', u'2', '3.4'],
         [u'B', u'3', '7.8', True],
         ['D', u'xyz', 9.0],
         ['E', 42]]
sorted(etl.typeset(table, 'foo'))
sorted(etl.typeset(table, 'bar'))
sorted(etl.typeset(table, 'baz'))


# diffheaders()
###############

import petl as etl
table1 = [['foo', 'bar', 'baz'],
          ['a', 1, .3]]
table2 = [['baz', 'bar', 'quux'],
          ['a', 1, .3]]
add, sub = etl.diffheaders(table1, table2)
add
sub

Esempio n. 7
0
from __future__ import division, print_function, absolute_import

# typeset()
###########

import petl as etl
table = [['foo', 'bar', 'baz'], ['A', 1, '2'], ['B', u'2', '3.4'],
         [u'B', u'3', '7.8', True], ['D', u'xyz', 9.0], ['E', 42]]
sorted(etl.typeset(table, 'foo'))
sorted(etl.typeset(table, 'bar'))
sorted(etl.typeset(table, 'baz'))

# diffheaders()
###############

import petl as etl
table1 = [['foo', 'bar', 'baz'], ['a', 1, .3]]
table2 = [['baz', 'bar', 'quux'], ['a', 1, .3]]
add, sub = etl.diffheaders(table1, table2)
add
sub

# diffvalues()
##############

import petl as etl
table1 = [['foo', 'bar'], ['a', 1], ['b', 3]]
table2 = [['bar', 'foo'], [1, 'a'], [3, 'c']]
add, sub = etl.diffvalues(table1, table2, 'foo')
add
sub