Skip to content

Commit

Permalink
cont
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Jul 2, 2018
1 parent 188951e commit d2a6555
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions datapackage_pipelines_budgetkey/processors/dump_to_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,19 @@ def format_datetime_rows(self, spec, rows):
formatters = {}
for f in spec['schema']['fields']:
if f['type'] == 'datetime':
logging.info('FIELD datetime: %r', f)
if f.get('format', 'default') in ('any', 'default'):
formatters[f['name']] = lambda x: x.strftime('%Y-%m-%dT%H:%M:%SZ')
formatters[f['name']] = lambda x: None if x is None else x.strftime('%Y-%m-%dT%H:%M:%SZ')
else:
formatters[f['name']] = lambda x: x.strftime(f['format'])
def formatter(f):
fmt = f['format']
def func(x):
if x is None:
return None
else:
return x.strftime(fmt)
return func
formatters[f['name']] = formatter(f)
id = lambda x: x

for row in rows:
Expand Down

0 comments on commit d2a6555

Please sign in to comment.