forked from CityOfPhiladelphia/delta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample_config.py
52 lines (45 loc) · 1.57 KB
/
sample_config.py
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
import re
def handle_currency(val):
""" This is an example of a function transform. Removes dollar signs and
decimal amounts from currency values."""
match = re.match('^(\$)?(\d+)(?=\.)?', val)
return match.group(2) if match else val
config = {
# Files to read from
'sources': {
'a': {
'file': '~/data/properties_2014.csv',
},
'b': {
'file': '~/data/properties_2015.csv',
# the csv module stumbles sometimes on non-utf-8 files, so use this
'encoding': 'ascii',
},
},
# This is not complete mapping of fields - just ones where the name changed
# in B. The directionality of the mapping is B => A.
'field_map': {
# B # A
'propertyid': 'prop_id',
},
# Field name to join on, as it appears in A
'key_field': 'prop_id',
# Transformations to apply before comparing. Use field names from A
# throughout (even in the B section).
'a': {
'market_value': handle_currency,
'unit_num': lambda x: x.lstrip('0'),
},
'b': {
'owner': 'rstrip',
},
},
# Fields to exclude from the comparison. Use fields from A, since anything
# that only appears in B will be excluded anyway.
'exclude_fields': [
'coordinates',
],
# Max number of rows to compare, usually for testing purposes. Note that
# they're sorted first, so you won't be comparing x number of random rows :)
'limit': None,
}