I'm not sure if my json file is unique but I couldn't find any other question/answers that worked.
My JSON file looks like:
{"UserID": "name1", "Timestamp": "1234"}
{"UserID": "name2", "Timestamp": "4321"}
{"UserID": "name3", "Timestamp": "1234"}
Is there a way for python to delete an entire line from the file?
This is what I've done so far:
open_file = open("times.json", 'r')
line = open_file.readline()
while line:
jsonLine = json.loads(line)
if line['Timestamp'] == '1234':
del line
open_file.close()
If the timestamp is 1234, I want it to delete the entire object so the file will just look like this:
{"UserID": "name2", "Timestamp": "4321"}
Thanks!