Skip to content

Commit

Permalink
Supports simpledb
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Jun 26, 2024
1 parent e7cdcfd commit 9c70fb7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from datapackage_pipelines.wrapper import process


def process_row(row, _1, spec, _2, params, _3):
resource = params['resource']
target_field = params['target-field']
source_field = params['source-field']
if spec['name'] == resource:
code = row[source_field]
code = code[2:]
nice_code = ''
while code:
nice_code += code[:2] + '.'
code = code[2:]
row[target_field] = nice_code[:-1]
return row


def modify_datapackage(dp, params, *_):
resource = params['resource']
target_field = params['target-field']
for res in dp['resources']:
if res['name'] == resource:
res['schema']['fields'].append({
'name': target_field,
'type': 'string',
'es:keyword': True
})
return dp


if __name__ == '__main__':
process(modify_datapackage=modify_datapackage,
process_row=process_row)
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,9 @@ def debug_source(source, debug):
description='''
שנת אישור התמיכה (או ביצוע התשלום, לפי value_kind).
''',
sample_values=[2017, 2023, 2024]
sample_values=[2017, 2023, 2024],
type='integer',
default=lambda row: row.get('year_requested') if row['value_kind'] == 'approval' else row.get('year_paid'),
),
dict(
name='amount',
Expand Down

0 comments on commit 9c70fb7

Please sign in to comment.