pythonjsonfiledirectoryfilenotfounderror

Error in loading JSON data - can't find the file


I've been trying to solve this issue, but right now I need some help. I'm trying to upload this JSON file (DBL) in Spyder IDE. I have stored the JSON-data file and the Spyder file, in the same map in order to read the JSON file, but it's not working.

My Python code:

import json 

file = open("dbl")

dbl = json.load(file)

print(dbl)

Every time I upload the json file, in the same map as the spyder.py file, it can't recognize the file directory.

I have stored the my .py file in the same folder as the JSON file.

This is the error message:

FileNotFoundError: [Errno 2] No such file or directory: 'dbl.json'

Solution

  • The file, in fact, does not exist. The actual filename is dbl.json.json.

    import json 
    file = open("dbl.json.json")
    dbl = json.load(file)
    print(dbl)