Skip to content

Instantly share code, notes, and snippets.

@ogawa
Created December 12, 2011 10:53
Show Gist options
  • Save ogawa/1466572 to your computer and use it in GitHub Desktop.
Save ogawa/1466572 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import csv
from icalendar import Calendar, Event
from datetime import datetime
ical = Calendar()
ical.add('version', '2.0')
ical.add('prodid', '-//test//hoge//EN')
reader = csv.reader(open(sys.argv[1]), delimiter=',')
for row in reader:
date = unicode(row[0], "cp932")
if date != u'名前':
event = Event()
d = date.split('/')
stime = unicode(row[1], "cp932").split(':')
etime = unicode(row[2], "cp932").split(':')
event.add('dtstart', datetime(int(d[0]),
int(d[1]),
int(d[2]),
int(stime[0]),
int(stime[1])))
event.add('dtend', datetime(int(d[0]),
int(d[1]),
int(d[2]),
int(etime[0]),
int(etime[1])))
event.add('summary', unicode(row[3].strip(), "cp932"))
event.add('location', unicode(row[6].strip(), "cp932"))
ical.add_component(event)
print ical
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment