0

i have funny error and i dont understand why. i trying to import in loop couple of files and enter to json, when i do it in for loop its not work and when i write the file name its work. its give me error

'utf-8' codec can't decode byte 0x80 in position 3131: invalid start byte

not work:

for fileName in os.listdir("files/greenhouses"):
with open("files/greenhouses/"+fileName, "rt") as f:
    jsonFile = json.load(f)
    plantingPoints = [PlantingPoint(details["DATE"], details["NAME"], details["OCCUPIED"]) for details in jsonFile[1:]]
    greenhouse = Greenhouse(jsonFile[0]["TEMPERATURE"], plantingPoints)

work:

for fileName in os.listdir("files/greenhouses"):
with open("files/greenhouses/1.json", "rt") as f:
    jsonFile = json.load(f)
    plantingPoints = [PlantingPoint(details["DATE"], details["NAME"], details["OCCUPIED"]) for details in jsonFile[1:]]
    greenhouse = Greenhouse(jsonFile[0]["TEMPERATURE"], plantingPoints)

what i can doo ?? i tried a lot of solutions that i found buy nothing work the json contain simple dictinary

IL994
  • 1
  • 2
  • Does this answer your question? ["for line in..." results in UnicodeDecodeError: 'utf-8' codec can't decode byte](https://stackoverflow.com/questions/19699367/for-line-in-results-in-unicodedecodeerror-utf-8-codec-cant-decode-byte) – Sören May 30 '22 at 16:31
  • still not give me another error for json json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) – IL994 May 30 '22 at 16:34
  • i not believe but the error showed because a secret file the it tried to import toWOW i want to cry hhhhh i spent couple of hours because of that – IL994 May 30 '22 at 16:46

0 Answers0