Skip to content

Instantly share code, notes, and snippets.

@spara
Created March 10, 2016 00:21
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 spara/27fe36c5ee9a24bbf01e to your computer and use it in GitHub Desktop.
Save spara/27fe36c5ee9a24bbf01e to your computer and use it in GitHub Desktop.
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