示例#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
# 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)