Skip to content

Instantly share code, notes, and snippets.

@takegue
Last active March 14, 2016 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takegue/77894c70a1dfa54333fa to your computer and use it in GitHub Desktop.
Save takegue/77894c70a1dfa54333fa to your computer and use it in GitHub Desktop.
NLP主要会議のGoogle Calendar生成スクリプト(http://www.cs.rochester.edu/~tetreaul/conferences.html)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
NLP 主要会議のGoogle Calendar日程作成用のscript
http://www.cs.rochester.edu/~tetreaul/conferences.html
"""
import pandas as pd
import dateutil as du
import re
path = '/path/to/file.csv'
schedule = pd.read_csv(path, sep='\t')
for col in schedule:
reg_name = col.strip().lower()
schedule[reg_name] = schedule[col]
if reg_name != col:
schedule.drop(col, axis=1, inplace=True)
schedule = schedule.fillna('')
data = []
for idx, conf_schedule in schedule.iterrows():
conf_name = conf_schedule['conference'].strip().strip('*')
du_parser = du.parser
dformat = '%m/%d/%Y'
if conf_schedule['submission date']:
date = conf_schedule['submission date']
date = date.strip().strip('*')
try:
dt = du_parser.parse(date)
except ValueError as e:
pass
else:
conf_info = {
'Subject': '{}:Submission Deadline'.format(conf_name),
'Start Date': dt.strftime(dformat),
'All Day Event': 'True',
'Location': conf_schedule['location'],
}
data.append(conf_info)
if conf_schedule['notification date']:
try:
date = conf_schedule['notification date']
dt = du_parser.parse(date)
except ValueError as e:
pass
else:
date = date.strip().strip('*')
conf_name = re.sub('(.\+)', '', conf_name)
conf_info = {
'Subject': '{}:Notification'.format(conf_name),
'Start Date': dt.strftime(dformat),
'All Day Event': 'True',
'Location': conf_schedule['location'],
}
data.append(conf_info)
if conf_schedule['conference date']:
conf_name = re.sub(r'\s*\(.+\)\s*', '', conf_name)
date_string = conf_schedule['conference date']
try:
dts = du_parser.parse(re.sub('-\d.', '', date_string))
dte = du_parser.parse(re.sub('\d.-', '', date_string))
except ValueError as e:
pass
else:
conf_info = {
'Subject': '{}:Conference'.format(conf_name),
'Start Date': dts.strftime(dformat),
'End Date': dte.strftime(dformat),
'All Day Event': 'True',
'Location': conf_schedule['location'],
}
data.append(conf_info)
df = pd.DataFrame().from_dict(data)
df = df.set_index('Subject')
print df.to_csv()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment