Skip to main content

I am trying to summarize Google Calendar events from the text output of Google Calendar. The export breaks the Description attribute across multiple lines (kinda like a permanent word wrap). Do you know of any way to walk through a text file and put relevant text back together (anti-word wrap)? I realize there is a Google Calendar reader but we are having some issues with connecting using 2FA. I was hoping the text output would allow me to get around fighting with the Google connection.

 

For example, I want to eventually get the DESCRIPTION into 1 line: DESCRIPTION:Training Document Rollout\\n\\n-::~:~::~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~::~:~::-\\nJoin with Google Meet: https://meet.google.com/we-m2dbz-xvc\\nOr dial: (US) +1 443-23471-4874 PIN:8were6975#\\nMore phone numbers: https://tel.meet/wje-mebz-xvc?pin=2freaag3037362148&hs=7\\n\\nLearn more about Meet at: https://support.google.com/a/users/answer/912345620\\n\\nPlease do not edit this section.\\n-::~:~::~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~::~:~::-

 

Here is an example of the text output from Google Calendar:

BEGIN:VEVENT

DTSTART:20220520T193000Z

DTEND:20220520T200000Z

DTSTAMP:20230331T151052Z

UID:0j3rr18m741qn7vt@google.com

X-GOOGLE-CONFERENCE:https://meet.google.com/wje-mebz-xde

CREATED:20220516T192256Z

DESCRIPTION:Training Document Rollout\\n\\n-::~:~::~:~:~:~:~:~:~:~:~:~:~:~:~:

 ~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~::~:~::-\\nJoin with Google Mee

 t: https://meet.google.com/we-m2dbz-xvc\\nOr dial: (US) +1 443-671-4874 PIN:

 867846975#\\nMore phone numbers: https://tel.meet/wje-mebz-xvc?pin=2freaag30373

 62148&hs=7\\n\\nLearn more about Meet at: https://support.google.com/a/users/

 answer/912345620\\n\\nPlease do not edit this section.\\n-::~:~::~:~:~:~:~:~:~:~

 :~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~::~:~::-

LAST-MODIFIED:20220516T193817Z

LOCATION:

SEQUENCE:0

STATUS:CONFIRMED

SUMMARY:Test

TRANSP:OPAQUE

ATTACH;FILENAME=Notes - Test;FMTTYPE=application/vnd.google-apps.document:h

 ttps://docs.google.com/document/d/1pnawrTurAaSJDnVuy-7RFasdrrgaaweqweqweddspddYR8GzI0n23

 WAs/edit

END:VEVENT

Due to the complexity of the format, I suspect the easiest is to use a PythonCaller and the iCalendar module to parse the events into FME features. To install the module from the command line:

fme.exe python -m pip install icalendar

I've attached a workspace template (FME 2020.2) that shows how to use the iCalendar module to parse all events into separate FME features:

import fme
import fmeobjects
from icalendar import Calendar, Event
 
class SplitEvents(object):
    def __init__(self):
        pass
        
    def input(self, feature):
        calendar_contents = feature.getAttribute('file_contents') or None
        if calendar_contents:
            cal = Calendar.from_ical(calendar_contents)
            for component in cal.walk():
                if component.name == "VEVENT":
                    new_feature = feature.clone()
                    props = component.property_items()
                    for prop in props:
                        name = prop 0]
                        value = component.decoded(name, default='')
                        if isinstance(value, bytes):
                            value = value.decode()
                        new_feature.setAttribute(name, str(value))
                    self.pyoutput(new_feature)
        
    def close(self):
        pass

 


Reply