예제 #1
0
파일: examples.py 프로젝트: datamade/petl
# addrownumbers
table1 = (('foo', 'bar'),
          ('A', 9),
          ('C', 2),
          ('F', 1))

from petl import addrownumbers, look
look(table1)
table2 = addrownumbers(table1)
look(table2)


# nthword
from petl import nthword
s = 'foo bar'
f = nthword(0)
f(s)
g = nthword(1)
g(s)


# search
table1 = (('foo', 'bar', 'baz'),
          ('orange', 12, 'oranges are nice fruit'),
          ('mango', 42, 'I like them'),
          ('banana', 74, 'lovely too'),
          ('cucumber', 41, 'better than mango'))

from petl import search, look
look(table1)
# search any field
예제 #2
0
파일: misc.py 프로젝트: DeanWay/petl
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


# nthword()
###########

import petl as etl
s = 'foo bar'
f = etl.nthword(0)
f(s)
g = etl.nthword(1)
g(s)

예제 #3
0
파일: examples.py 프로젝트: aklimchak/petl
# addrownumbers
table1 = (('foo', 'bar'),
          ('A', 9),
          ('C', 2),
          ('F', 1))

from petl import addrownumbers, look
look(table1)
table2 = addrownumbers(table1)
look(table2)


# nthword
from petl import nthword
s = 'foo bar'
f = nthword(0)
f(s)
g = nthword(1)
g(s)


# search
table1 = (('foo', 'bar', 'baz'),
          ('orange', 12, 'oranges are nice fruit'),
          ('mango', 42, 'I like them'),
          ('banana', 74, 'lovely too'),
          ('cucumber', 41, 'better than mango'))

from petl import search, look
look(table1)
# search any field
예제 #4
0
# 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

# nthword()
###########

import petl as etl
s = 'foo bar'
f = etl.nthword(0)
f(s)
g = etl.nthword(1)
g(s)