Created
April 30, 2021 10:17
-
-
Save almugabo/7b9d4db9445d49b64f9f467f6b0e0a88 to your computer and use it in GitHub Desktop.
research news template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from string import Template | |
xDocHead = '''<!DOCTYPE html> | |
<html><head> | |
<meta http-equiv="content-type" content="text/html; charset=windows-1252"> | |
<style> | |
.title_orange { | |
font-family: Verdana, Geneva, sans-serif; | |
font-size: 14px; | |
color: #ff6633; | |
font-weight: bold; | |
} | |
.picture { | |
padding-right: 10px; | |
height: 140px; | |
width: 130px; | |
padding-top: 10px; | |
padding-bottom: 10px; | |
} | |
.header { | |
font-family: Tahoma, Geneva, sans-serif; | |
font-size: 36px; | |
background-repeat: no-repeat; | |
} | |
.background_row { | |
background-image: url(background_row.gif); | |
background-repeat: no-repeat; | |
} | |
.header2 { | |
font-family: Tahoma, Geneva, sans-serif; | |
font-size: 36px; | |
color: #ff6633; | |
} | |
.header3 { | |
font-family: Tahoma, Geneva, sans-serif; | |
font-size: 14px; | |
padding-left: 100px; | |
color: #666666; | |
font-weight: bold; | |
} | |
.sub_title { | |
font-family: Verdana, Geneva, sans-serif; | |
font-size: 12px; | |
color: #999999; | |
font-weight: bold; | |
} | |
.sub_sub_title { | |
font-family: Verdana, Geneva, sans-serif; | |
font-size: 10px; | |
font-weight: bold; | |
color: #000; | |
} | |
hr { | |
color: #CCC; | |
background: #CCC; | |
width: 100%; | |
height: 1px; | |
} | |
/* unvisited link */ | |
a:link { | |
color: #ff6633; | |
} | |
/* visited link */ | |
a:visited { | |
color: #ff6633; | |
} | |
/* mouse over link */ | |
a:hover { | |
color: #999999; | |
text-decoration: underline; | |
} | |
/* selected link */ | |
a:active { | |
color: #999999; | |
text-decoration: underline; | |
} | |
</style> | |
</head> | |
<body> | |
<table cellspacing="0" cellpadding="0" border="0"> | |
<tbody><tr> | |
<td colspan="3" height="19"> </td> | |
</tr> | |
<tr class="background_row"> | |
<td colspan="3" class="header" height="130"> Research and Innovation to Tackle the COVID-19 Pandemic | |
<p class="header3"> A selection of Discoveries, Inventions, Developments to which EU funding has contributed</p></td> | |
</tr> | |
<td> </td> | |
\n''' | |
xDocTail = '''\n | |
</tbody></table> | |
</body></html> | |
''' | |
xEntryTpl = Template(''' | |
<tr> | |
<td width="130"> </td> | |
<td width="130" height="130"><img src=$picture class="picture" width="122" height="114"></td> | |
<td width="880"><p class="title_orange">$summary_title</p> | |
<p class="sub_title">$summary_text</p> | |
<a href="$pub_id_doi_link" target="_blank">$pub_id_doi_text</a> | |
<p><span class="sub_sub_title">$pub_date</span> </p> | |
</td> | |
</tr> | |
''') | |
xEntry_lst = [] | |
for x in df1.iterrows(): | |
xDictVal = dict(x[1]) | |
#xDictVal['pub_date'] = 'xxx' | |
xDictVal['pub_id_doi_link'] = 'http://dx.doi.org/' + xDictVal['pub_id_doi'] | |
xDictVal['pub_id_doi_text'] = xDictVal['pub_id_doi'] | |
xEntry = xEntryTpl.substitute(xDictVal) | |
xEntry_lst.append(xEntry ) | |
xEntry_lst_str = '\n'.join(xEntry_lst) | |
xFileDest = 'xtest_covid_19_eu.html' | |
xContent = xDocHead + xEntry_lst_str + xDocTail | |
with open(xFileDest, 'w') as ff: | |
ff.write(xContent) | |
print('OK') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment