Skip to content

Instantly share code, notes, and snippets.

@AhmetCanSolak
Created January 22, 2018 17:44
Show Gist options
  • Save AhmetCanSolak/6f44856f0fd591969761f0c68bc75692 to your computer and use it in GitHub Desktop.
Save AhmetCanSolak/6f44856f0fd591969761f0c68bc75692 to your computer and use it in GitHub Desktop.
# Function to flatten dictionary
def flattenDict(dictionary):
results={}
for key,value in dictionary.items():
if isinstance(value,dict):
tempDict = flattenDict(value)
for subkey,subvalue in tempDict.items():
results[key+"."+subkey]=subvalue
else:
results[key]=value
return results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment