def test_parsecounts(): table = (('foo', 'bar', 'baz'), ('A', 'aaa', 2), ('B', u'2', '3.4'), (u'B', u'3', u'7.8', True), ('D', '3.7', 9.0), ('E', 42)) actual = parsecounts(table, 'bar') expect = (('type', 'count', 'errors'), ('float', 3, 1), ('int', 2, 2)) ieq(expect, actual)
def test_parsecounts(): table = (('foo', 'bar', 'baz'), ('A', 'aaa', 2), ('B', '2', '3.4'), ('B', '3', '7.8', True), ('D', '3.7', 9.0), ('E', 42)) actual = parsecounts(table, 'bar') expect = (('type', 'count', 'errors'), ('float', 3, 1), ('int', 2, 2)) ieq(expect, actual)
def test_parsecounts(): table = ( ("foo", "bar", "baz"), ("A", "aaa", 2), ("B", u"2", "3.4"), (u"B", u"3", u"7.8", True), ("D", "3.7", 9.0), ("E", 42), ) actual = parsecounts(table, "bar") expect = (("type", "count", "errors"), ("float", 3, 1), ("int", 2, 2)) ieq(expect, actual)
counter, errors = etl.parsecounter(table, 'bar') counter.most_common() errors.most_common() # parsecounts() ############### import petl as etl table = [['foo', 'bar', 'baz'], ['A', 'aaa', 2], ['B', u'2', '3.4'], [u'B', u'3', u'7.8', True], ['D', '3.7', 9.0], ['E', 42]] etl.parsecounts(table, 'bar') # typecounter() ############### import petl as etl table = [['foo', 'bar', 'baz'], ['A', 1, 2], ['B', u'2', '3.4'], [u'B', u'3', u'7.8', True], ['D', u'xyz', 9.0], ['E', 42]] etl.typecounter(table, 'foo').most_common() etl.typecounter(table, 'bar').most_common() etl.typecounter(table, 'baz').most_common()