Skip to content

Instantly share code, notes, and snippets.

@stevenklar
Created January 13, 2020 10:13
Show Gist options
  • Select an option

  • Save stevenklar/b6543554cd867993ec834e41032c9400 to your computer and use it in GitHub Desktop.

Select an option

Save stevenklar/b6543554cd867993ec834e41032c9400 to your computer and use it in GitHub Desktop.
from flatten_json import flatten
import json
print("> Open File")
file = open("FILEPATH","r")
print("> Print File")
data = file.read()
print("> Load json from file")
translationDict = json.loads(data)
print("> Flatten")
flattenedData = flatten(translationDict, '.')
maxLength = 0
for data in flattenedData:
dataLen = len(data)
if maxLength < dataLen:
# print("%d is bigger than last %d" % (dataLen, maxLength))
maxLength = dataLen
else:
# print("%d is less than last %d" % (dataLen, maxLength))
print(maxLength)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment