i am currently having problem saving one combined json file in my python code but what it does it one saves the latest "result" in json file and not all of them so i had to save all the different results in seperate json file but instead i want to store it in single faculty.json file, how can i do that?
here is my code:
outputPath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'output')
if os.path.isdir(outputPath) is False:
os.makedirs(outputPath)
result = {'empid': facultyID, 'name': name, 'school': school, 'designation': designation, 'room': room, 'intercom': intercom, 'email': email, 'division': division, 'open_hours': openHours}
with open('output/faculty.json', 'w') as outfile:
json.dump(result, outfile)
return result
'a'ppend mode and write more data to it? But then you'll not end up with a valid JSON file.returnstatement I guess it's part of a function that you're calling in a loop.