Skip to content

Instantly share code, notes, and snippets.

@netmarkjp
Last active December 18, 2015 09:39
Show Gist options
  • Save netmarkjp/5763047 to your computer and use it in GitHub Desktop.
Save netmarkjp/5763047 to your computer and use it in GitHub Desktop.
#coding: utf-8
import csv
import re
reader=csv.reader(open('data.csv'),dialect='excel')
fixed=[]
for row in reader:
data={ 'waku':row[3],
'title':row[4],
'description':row[5],
'level':row[6],
'image':row[7],
'speaker':row[8],
'profile':row[9],
'status':row[13],
}
if data.get('status') == 'fix':
newline_pattern=r'(\r\n|\r|\n)'
url_pattern=r'(http[:/a-zA-Z0-9\?&=\.\-%_#]+)'
img_url_pattern_rev=r'<a target="_blank" href="(http[:/a-zA-Z0-9\?&=\.\-%_#]+)\.jpg">(http[:/a-zA-Z0-9\?&=\.\-%_#]+)\.jpg</a>'
data['description']=re.sub(newline_pattern,'<br />\n',data['description'])
data['description']=re.sub(url_pattern,
r'<a target="_blank" href="\1">\1</a>',data['description'])
#data['description']=re.sub(r'','',data['description'])
data['level']=re.sub(newline_pattern,'<br />\n',data['level'])
data['speaker']=re.sub(newline_pattern,'<br />\n',data['speaker'])
data['speaker']=re.sub(url_pattern,
r'<a target="_blank" href="\1">\1</a>',data['speaker'])
data['profile']=re.sub(newline_pattern,'<br />\n',data['profile'])
data['profile']=re.sub(url_pattern,
r'<a target="_blank" href="\1">\1</a>',data['profile'])
data['profile']=re.sub(img_url_pattern_rev,
r'<img align="right" hspace="10" src="\1.jpg" style="height:128px"/>',data['profile'])
if data['image'] != '':
data['image']='<img align="right" hspace="10" src="%(image)s" style="height:128px"/>'%data
fixed.append(data)
for data in fixed:
if data.get('waku') != 'LT' and data.get('waku') != 'ショートセッション':
print '''
<h3>「%(title)s」</h3>
<ul>
<li> 対象: %(level)s
</li>
<li> 概要: <br />
%(description)s
</li>
<li>%(image)s
%(speaker)s<br />
%(profile)s
</li><br clear='left' />
</ul>
'''%data
print '<h2>ショートセッション</h2>'
for data in fixed:
if data.get('waku') == 'ショートセッション':
print '''
<h3>「%(title)s」</h3>
<ul>
<li>%(image)s
%(speaker)s<br />
%(profile)s
</li><br clear='left' />
</ul>
'''%data
print '<h2>LT</h2>'
for data in fixed:
if data.get('waku') == 'LT':
print '''
<h3>「%(title)s」</h3>
<ul>
<li>%(image)s
%(speaker)s<br />
%(profile)s
</li><br clear='left' />
</ul>
'''%data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment