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
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:479d65b161afda29d9bddd2391ff8427ccdc214abf259212993ef9b90a02a3d4" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<div id="chartContainer"> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://dimplejs.org/dist/dimple.v2.1.2.min.js"></script> | |
<script type="text/javascript"> | |
var svg = dimple.newSvg("#chartContainer", 590, 400); |
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
#clean the religion and denomination names | |
def clean_religion(entry): | |
new_entry = entry.lower() | |
if new_entry == "latter_day_saints": | |
return "Mormon" | |
if new_entry == "roman_catholic": | |
return "Catholic" | |
if 'jehovahs' in new_entry: | |
return "Jehovah's Witness" | |
return entry.replace('_',' ').title() |
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
def count_tags(filename): | |
tags = {} | |
for item, elem in ET.iterparse(filename): | |
if elem.tag not in tags: | |
tags[elem.tag] = 1 | |
else: | |
tags[elem.tag] += 1 | |
return tags | |
tags = count_tags('austin_texas.osm') |
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
def process_line(line, fields): | |
classification_list = ['family', 'class', 'phylum','order','kingdom', 'genus'] | |
spider_dict = {} | |
spider_dict['classification'] = {} | |
for field in fields: | |
new_value = line[field].strip() | |
if line[field].strip() == 'NULL': | |
new_value = None | |
if fields[field] == 'label': | |
new_value = re.sub(r'\([^)]*\)', '', line[field]).strip() #http://stackoverflow.com/questions/640001/how-can-i-remove-text-within-parentheses-with-a-regex |
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
def process_file(filename, fields): | |
classification_list = ['family', 'class', 'phylum','order','kingdom', 'genus'] | |
process_fields = fields.keys() | |
data = [] | |
with open(filename, "r") as f: | |
reader = csv.DictReader(f) | |
for i in range(3): | |
l = reader.next() | |
for line in reader: |