Skip to content

Commit fbec359

Browse files
committed
#30 updated talk descriptions
1 parent 30e8e0f commit fbec359

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

talkmap.ipynb

+21-13
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"```bash\n",
1212
"sudo apt install jupyter\n",
1313
"sudo apt install python3-pip\n",
14-
"pip install getorg --upgrade\n",
14+
"pip install python-frontmatter getorg --upgrade\n",
1515
"```\n",
1616
"\n",
1717
"After which you can run this from the `_talks/` directory, via:\n",
@@ -32,7 +32,8 @@
3232
"outputs": [],
3333
"source": [
3434
"# Start by installing the dependencies\n",
35-
"!pip install getorg --upgrade\n",
35+
"!pip install python-frontmatter getorg --upgrade\n",
36+
"import frontmatter\n",
3637
"import glob\n",
3738
"import getorg\n",
3839
"from geopy import Nominatim"
@@ -76,17 +77,24 @@
7677
"source": [
7778
"# Perform geolocation\n",
7879
"for file in g:\n",
79-
" with open(file, 'r') as f:\n",
80-
" lines = f.read()\n",
81-
" if lines.find('location: \"') > 1:\n",
82-
" loc_start = lines.find('location: \"') + 11\n",
83-
" lines_trim = lines[loc_start:]\n",
84-
" loc_end = lines_trim.find('\"')\n",
85-
" location = lines_trim[:loc_end]\n",
86-
" \n",
87-
" \n",
88-
" location_dict[location] = geocoder.geocode(location)\n",
89-
" print(location, \"\\n\", location_dict[location])\n"
80+
" # Read the file\n",
81+
" data = frontmatter.load(file)\n",
82+
" data = data.to_dict()\n",
83+
"\n",
84+
" # Press on if the location is not present\n",
85+
" if 'location' not in data:\n",
86+
" continue\n",
87+
"\n",
88+
" # Prepare the description\n",
89+
" title = data['title'].strip()\n",
90+
" venue = data['venue'].strip()\n",
91+
" location = data['location'].strip()\n",
92+
" description = f\"{title}\\n{venue}; {location}\"\n",
93+
" print(description)\n",
94+
"\n",
95+
" # Geocode the location and report the status\n",
96+
" location_dict[description] = geocoder.geocode(location)\n",
97+
" print(description, location_dict[description])"
9098
]
9199
},
92100
{

0 commit comments

Comments
 (0)