Commit d2a62705 authored by Tarik Graba's avatar Tarik Graba 😷
Browse files

Initial script

parents
#! /usr/bin/env python3
import csv
from icalendar import Calendar, Event
from datetime import datetime
from pytz import timezone
CSV_FNAME = 'PACT.csv'
ICS_FNAME = 'PACT.ics'
date_fmt="%d/%m/%Y %H:%M"
date_locale = timezone('Europe/Paris')
cal = Calendar()
cal['summary'] = 'EDT PACT'
with open(CSV_FNAME) as csvfile:
seances = csv.reader(csvfile, delimiter=';', quotechar='"')
# Skip the header
entete = next(seances)
for seance in seances:
event = Event()
description = seance[6]
date_debut = " ".join([seance[0], seance[2]])
date_fin = " ".join([seance[0], seance[3]])
ddate_d = date_locale.localize(datetime.strptime(date_debut, date_fmt))
ddate_f = date_locale.localize(datetime.strptime(date_fin , date_fmt))
event.add('summary', description)
event.add('dtstart', ddate_d)
event.add('dtend', ddate_f)
cal.add_component(event)
with open(ICS_FNAME, 'wb') as icsfile:
icsfile.write(cal.to_ical())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment