Esempio n. 1
0
 def test_is_null(self):
     nt.assert_false(ft.is_null(''))
     nt.assert_false(ft.is_null(' '))
     nt.assert_false(ft.is_null(False))
     nt.assert_false(ft.is_null('0'))
     nt.assert_false(ft.is_null(0))
     nt.assert_true(ft.is_null('', blanks_as_nulls=True))
     nt.assert_true(ft.is_null(' ', blanks_as_nulls=True))
Esempio n. 2
0
def normalize(records, **kwargs):
    first = records.next()
    reconstituted = it.chain([first], records)
    filterfunc = lambda x: x[0].startswith('y')
    base = dict(it.ifilterfalse(filterfunc, first.items()))

    for record in reconstituted:
        values = it.ifilter(filterfunc, record.items())

        for addon in ({'year': v[0][1:], 'value': v[1]} for v in values):
            if not ft.is_null(addon['value'], blanks_as_nulls=True):
                yield pr.merge([base, addon])