Welcome to Python MergeCal documentation!¶
Installation & Usage
Project Info
- Changelog
- v0.5.0 (2025-02-06)
- v0.4.2 (2025-02-04)
- v0.4.1 (2025-01-31)
- v0.4.0 (2025-01-29)
- v0.3.14 (2025-01-19)
- v0.3.13 (2024-12-04)
- v0.3.12 (2024-12-03)
- v0.3.11 (2024-11-29)
- v0.3.10 (2024-11-23)
- v0.3.9 (2024-11-19)
- v0.3.8 (2024-11-08)
- v0.3.7 (2024-11-01)
- v0.3.6 (2024-10-22)
- v0.3.5 (2024-10-13)
- v0.3.4 (2024-10-06)
- v0.3.3 (2024-10-04)
- v0.3.2 (2024-10-01)
- v0.3.1 (2024-09-10)
- v0.3.0 (2024-09-09)
- v0.2.0 (2024-09-06)
- v0.1.0 (2024-09-05)
- Contributing
Python MergeCal¶
Documentation: https://mergecal.readthedocs.io
Source Code: https://github.com/mergecal/python-mergecal
A Python library to merge iCalendar feeds.
Merging two calendars might look easy but it is not! Here is a list of features:
✅ Google Calendar Compatibility (X-WR-TIMEZONE)
✅ Add Timezones in the right place
✅ handle duplicated events
✅ handle modifications (deletion, addition) of events
Installation¶
Install this via pip (or your favorite package manager):
pip install mergecal
Usage¶
Python API¶
You can use MergeCal in your Python code as follows:
>>> from mergecal import merge_calendars
>>> from icalendar import Calendar
# Load your calendars
# CALENDARS = pathlib.Path("to/your/calendar/directory")
>>> calendar1 = Calendar.from_ical((CALENDARS / "one_event.ics").read_bytes())
>>> calendar2 = Calendar.from_ical((CALENDARS / "another_event.ics").read_bytes())
# Merge the calendars
>>> merged_calendar : Calendar = merge_calendars([calendar1, calendar2])
# Write the merged calendar to a file
>>> (CALENDARS / "merged_calendar.ics").write_bytes(merged_calendar.to_ical())
998
# The merged calendar will contain all the events of both calendars
>>> [str(event["SUMMARY"]) for event in calendar1.walk("VEVENT")]
['Event 1']
>>> [str(event["SUMMARY"]) for event in calendar2.walk("VEVENT")]
['Event 2']
>>> [str(event["SUMMARY"]) for event in merged_calendar.walk("VEVENT")]
['Event 1', 'Event 2']
Command Line Interface (CLI)¶
MergeCal also provides a command-line interface for easy merging of calendar files:
# Basic usage
mergecal calendar1.ics calendar2.ics -o merged_calendar.ics
# Specifying custom PRODID
mergecal calendar1.ics calendar2.ics -o merged_calendar.ics --prodid "-//My Organization//MergeCal 1.0//EN"
For more options and information, use the help command:
mergecal --help
Contributors ✨¶
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Credits¶
This package was created with Copier and the browniebroke/pypackage-template project template.