Skip to Content

from datetime import datetime

input_str = "SGKI-002-JAVHD-TODAY-1023202302-30-59 Min" parsed = parse_string(input_str) print(parsed) This example provides a very basic way to approach parsing such a string and might need to be adjusted based on the exact requirements and variability of your input data.

def parse_string(input_str): # Assuming the date/time part always follows the same format date_time_str = input_str[len("SGKI-002-JAVHD-TODAY-"):22] try: date_time_obj = datetime.strptime(date_time_str, '%m%d%Y%H-%M-%S') return { "identifier": input_str[:len("SGKI-002-JAVHD-TODAY-")], "date_time": date_time_obj, "duration": input_str[-3:] # Very simplistic, might need adjustment } except Exception as e: print(f"An error occurred: {e}") return None

Author Profile Photo

Shannon Brady

Shannon Brady is a Local Alert Meteorologist with KTVZ News. Learn more about Shannon here.

BE PART OF THE CONVERSATION

KTVZ is committed to providing a forum for civil and constructive conversation.

Please keep your comments respectful and relevant. You can review our Community Guidelines by clicking here

If you would like to share a story idea, please submit it here.