I have the Python code below in which I am attempting to access a folder called downloaded that contains multiple JSON object files.
Within each JSON there is a value keyword
for which I need to extract and add to the list named keywordList
I've attempted by adding the filenames to fileList
(which works ok), but I cannot seem to loop through the fileList
and extract the keyword
connected.
Amy help much appreciated, thanks!
import os
os.chdir('/Users/Me/Api/downloaded')
fileList = []
keywordList = []
for filenames in os.walk('/Users/Me/Api/downloaded'):
fileList.append(filenames)
for file in filenames:
with open(file, encoding='utf-8', mode='r') as currentFile:
keywordList.append(currentFile['keyword'])
print(keywordList)