etl.py

1
2
3
4
5
6
7
8
from functools import reduce


def transform(old):
    # Reversed dicts
    dicts = ({word.lower(): n for word in words} for n, words in old.items())
    # Merge dicts together
    return reduce(lambda a, b: {**a, **b}, dicts)

Comments

Was about to archive this at v1 but wasn't happy so decided to have another go. I think functional languages may be slowly corrupting me.

helenst commented 29 March 2016 at 07:51 UTC

You're not logged in right now. Please login via GitHub to comment