I have a list of 1,500 Emoji dictionaries in a JSON file, and I wanted to import them into my python code, I read the file and convert it to a python dictionary, but now I have only 143 entries. How can I import all emoji into my code, this is my code.
import sys
import ast
file = open('emojidescription.json','r').read()
non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0xfffd)
emoji_dictionary = ast.literal_eval(file.translate(non_bmp_map))
keys = list(emoji_dictionary["emojis"][0].keys())
values = list(emoji_dictionary["emojis"][0].values())
file_write = open('output.txt','a')
print(len(keys))
for i in range(len(keys)):
try:
content = 'word = word.replace("{0}", "{1}")'.format(keys[i],values[i][0])
except Exception as e:
content = 'word = word.replace("{0}", "{1}")'.format(keys[i],'')
print(content)
file_write.close()
This is my input example.
{
"emojis": [
{
"๐จโ๐": ["Graduate"],
"ยฉ": ["Copy right"],
"ยฎ": ["Registered"],
"๐จโ๐ฉโ๐ง": ["family"],
"๐ฉโโค๏ธโ๐โ๐ฉ": ["love"],
"โข": ["trademark"],
"๐จโโคโ๐จ": ["love"],
"โ": ["time"],
"โ": ["wait"],
"โญ": ["star"],
"๐": ["Elephant"],
"๐": ["Cat"],
"๐": ["ant"],
"๐": ["cock"],
"๐": ["cock"],
This is my result, and 143 indicates the amount of emoji.
143
word = word.replace ("", "family")
word = word.replace ("โ", ")
word = word.replace ("โฅ", ")
word = word.replace ("โ ", ")
word = word.replace ("โ", "wait")