File: headers.py

package info (click to toggle)
python-petl 1.7.17-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,224 kB
  • sloc: python: 22,617; makefile: 109; xml: 9
file content (64 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from __future__ import division, print_function, absolute_import


# rename()
##########

import petl as etl
table1 = [['sex', 'age'],
          ['m', 12],
          ['f', 34],
          ['-', 56]]
# rename a single field
table2 = etl.rename(table1, 'sex', 'gender')
table2
# rename multiple fields by passing a dictionary as the second argument
table3 = etl.rename(table1, {'sex': 'gender', 'age': 'age_years'})
table3


# setheader()
#############

import petl as etl
table1 = [['foo', 'bar'],
          ['a', 1],
          ['b', 2]]
table2 = etl.setheader(table1, ['foofoo', 'barbar'])
table2


# extendheader()
################

import petl as etl
table1 = [['foo'],
          ['a', 1, True],
          ['b', 2, False]]
table2 = etl.extendheader(table1, ['bar', 'baz'])
table2


# pushheader()
##############

import petl as etl
table1 = [['a', 1],
          ['b', 2]]
table2 = etl.pushheader(table1, ['foo', 'bar'])
table2


# skip()
#########

import petl as etl
table1 = [['#aaa', 'bbb', 'ccc'],
          ['#mmm'],
          ['foo', 'bar'],
          ['a', 1],
          ['b', 2]]
table2 = etl.skip(table1, 2)
table2