Last active
May 1, 2021 07:52
-
-
Save shreyasms17/95e4eeee2334a2d2dfaa7891cf533f25 to your computer and use it in GitHub Desktop.
AutoFlatten get_structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_structure(self, col_list): | |
''' | |
Description: | |
This function gets the structure to the traversal to array field in the schema | |
:param col_list: [type: list] contains list of fields that are to be exploded | |
:return structure: [type: dict] contains the hierarchical mapping for array fields | |
''' | |
structure = {'json' : {}} | |
for val in col_list: | |
arr = val.split('.') | |
a = structure['json'] | |
for i in range(1,len(arr)): | |
if not a.__contains__(arr[i]): | |
a[arr[i]] = {} | |
a = a[arr[i]] | |
return structure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment