Python Typeerror With For Logic Iterating Data Values
I'm having a problem getting the for loop of the json.load() function to read through the 'alarmst' fields and bring back their values. I have working code above the problem code
Solution 1:
Your issue is the line:
foralarm in tag["alarmst"]:
csv_file.writerow(alarm['dateStatus'],alarm['dateStart'], ...)
Notice that in your data, the value for alarmst
is a JSON object, which in python is translated into a dictionary. So when you iterate over it, you end up with the keys: i.e. alarm
will be "dateStatus", "dateStart", "status", ...
.
Replace it with:
alarm = tag["alarmst"]
csv_file.writerow(...)
Post a Comment for "Python Typeerror With For Logic Iterating Data Values"