NWS Alerts using python script

  • 1
  • Problem
  • Updated 2 years ago
I am having a problem with weather alerts not reading correctly in python script in linux (debian wheezy - raspberry pi). I keep getting the error TypeError: list indices must be integers, not str. I am trying to filter the alerts based on the "type" field and display information from the "description", "date", and "expires" fields. The problem is that the information I am trying to get requires it to be strings, not integers. Hope you can help.
Some code is listed below.

type = str(parsed_json['alerts']['type'])
description = str(parsed_json['query_zone']['alerts']['type']['description'])
date = str(parsed_json['alerts']['type']['description']['date'])
expires = str(parsed_json['alerts']['type']['description']['date']['expires'])
Photo of FF13617


  • 1 Post
  • 0 Reply Likes

Posted 6 years ago

  • 1
Photo of afelicioni


  • 227 Posts
  • 43 Reply Likes
What API feature rising the issue is being used by the project?
Does parsed_json is referencing/assigned as an object or an array of objects?
Photo of Marvin Williams

Marvin Williams

  • 1 Post
  • 0 Reply Likes