I want to extract information from an .ics file and I am having problems with certain parameters. When extracting "categories" the encoded information appears, and with the "trigger" parameter I can't directly extract anything. I have tried many alternatives and none have worked.
import icalendar
from icalendar import Calendar, Event, vCalAddress, vText
from datetime import datetime
from pathlib import Path
import os
datos = {"CATEGORIES": [],
"DTSTART": [],
"SUMMARY": [],
"DESCRIPTION": [],
"TRIGGER": [],
}
e = open('C:/Users/XXX/PycharmProjects/XXX/Calendario ALEMANIA.ics', 'r', encoding='utf-8')
ecal = icalendar.Calendar.from_ical(e.read())
for component in ecal.walk():
if component.name == "VEVENT":
categories = component.get("categories")
datos["CATEGORIES"].append(categories)
dtstart = component.decoded("dtstart")
datos["DTSTART"].append(dtstart)
summary = component.get("summary")
datos["SUMMARY"].append(summary)
description = component.decoded("description")
datos["DESCRIPTION"].append(description)
trigger = component.get("trigger")
datos["TRIGGER"].append(trigger)
e.close()
print(datos)
I get this result in the two mentioned categories:
{'TRIGGER': [None], 'CATEGORIES': [<icalendar.prop.vCategory object at 0x0000011240C056C0>]}
When actually (info from the .ics) should give me:
{'TRIGGER': [-PT15M], 'CATEGORIES': [Categoría Roja]}
I have tried many functions and I GET NOTHING... Some of them:
.decode('utf-8') , component.decode("categories") , .from_ical() , .ical()...
Anyone who can help me? Regards!