I have a folder with multiple subdirectories that contain a number of .json files.
I am only interested in getting the content of .json files that are titled "all_content.json" in each subdirectory (this file has the same name in each directory).
Then I want to take the content from each file and add it to one pandas dataframe, where the column title is the key (e.g.: column 1 = content and column 2 = date)
{ "content": "The flowers are so pretty here", "date": "1999-10-22" }
This is what I have tried so far, but I am not sure how to select the right file, open it and then save the content:
path = './folders'
for root, dirs, files in os.walk(path):
print(files) # returns list of all files in the folder
for file in files:
if file.endswith("all_content.json"):
print(file)
with open(file) as fp:
data = json.load(fp)