Created
March 10, 2016 00:21
-
-
Save spara/27fe36c5ee9a24bbf01e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import json, codecs | |
topics = ["CoreOS", | |
"Google", | |
"Microsoft", | |
"Joyent", | |
"ECS", | |
"Rancher", | |
"Hashicorp", | |
"Swarm", | |
"Machine", | |
"Engine", | |
"Hub", | |
"Compose", | |
"Kubernetes", | |
"Mesos", | |
"OpenShift", | |
"Red Hat", | |
"RedHat" | |
"ECS", | |
"Azure", | |
"Fleet", | |
"ETCD", | |
"Consul", | |
"Terraform", | |
"hackathon", | |
"tutorial", | |
"lightning talk", | |
"captains" | |
] | |
events_by_topic = [] | |
tags_list = [] | |
tagged_events =[] | |
with open('events.json','r') as f: | |
for group in f: | |
events = json.loads(group) | |
for e in events: | |
try: | |
tags_list = [] | |
desc = e.get('description') | |
for t in topics: | |
if t.lower() in desc.lower(): | |
tags_list.append(t) | |
# events_by_topic.append(e) | |
except: | |
pass | |
if len(tags_list) > 0: | |
e[u"tags"]=tags_list | |
tagged_events.append(e) | |
with codecs.open('tagged_events.json','w', encoding='utf-8') as of: | |
json.dump(tagged_events, of,sort_keys=True, ensure_ascii=False) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment