0

I'd like export (possibly automatically) from google calendar an .ics file and convert it to a text diary (maybe .md, or .html). A way there is, with the IFTTT scripts, but is too commercial, I am searching for a open source solution.

1

Not sure there's any pre-baked solution, but if you know a bit of Python you can try ics.py. Just pip install ics then:

from ics import Calendar

md_template = """
### {start}
*{name}*: {desc}""" 

with open("basic.ics") as f:
   cal = Calendar(f.read())

print("## Calendar")
for e in sorted(cal.events):
    print(md_template.format(start=e.begin.humanize(), name=e.name,
                             desc=e.description))
  • I get this error: "ImportError: cannot import name Calendar" – Duns Nov 20 '18 at 9:57
  • What's your Python file called? Make sure it isn't called ics.py too – declension Nov 20 '18 at 9:58
  • In effect (how can youi know?): "python convert-ics-to-diary.py Traceback (most recent call last): File "convert-ics-to-diary.py", line 1, in <module> from ics import Calendar File "/mnt/dati/schede/desktop/ics.py", line 3, in <module> from ics import Calendar, Event ImportError: cannot import name Calendar" I see a new file ics.pyc, with a wrong ecoding – Duns Nov 20 '18 at 10:13
  • erm you should probably remove all .pyc files and try again. If a Python file has the same name as a module it's importing, it will try to import itself – declension Nov 20 '18 at 11:06
  • Now I get this error: "File "/home/duns/.local/lib/python2.7/site-packages/arrow/parser.py", line 119, in parse_iso return self._parse_multiformat(string, formats) File "/home/duns/.local/lib/python2.7/site-packages/arrow/parser.py", line 283, in _parse_multiformat raise ParserError('Could not match input to any of {0} on \'{1}\''.format(formats, string)) arrow.parser.ParserError: Could not match input to any of [u'YYYY-MM-DDTHH:mm'] on '20181119T084520Z'' – Duns Nov 20 '18 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.