Skip to content

Commit c6382b6

Browse files
committed
scripts to add all available dataset shells for all groups containing collected data
1 parent a38aeef commit c6382b6

12 files changed

+525
-1
lines changed

make_grp.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def make_grp(name,title):
3737
return create_group
3838
pprint.pprint(create_group)
3939

40+
make_grp('diversity','Diversity')
4041
#make_grp('diverse_community','Diverse Community')
4142
#make_grp('access_to_health_care','Access to Health Care')
4243
#make_grp('built_environment','Built Environment')
@@ -47,4 +48,4 @@ def make_grp(name,title):
4748
#make_grp('mental_health','Mental Health')
4849
#make_grp('sense_of_community','Sense of Community')
4950
#make_grp('substance_abuse_prevention','Substance Abuse Prevention')
50-
make_grp('meeting_basic_needs','Meeting Basic Needs')
51+
#make_grp('meeting_basic_needs','Meeting Basic Needs')

make_packages.py

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python
2+
import urllib2
3+
import urllib
4+
import json
5+
import pprint
6+
import ckan_api
7+
from make_pkg import make_pkg
8+
9+
#homeless_dict = {
10+
# "name" : "homeless",
11+
# "title" : "Number of Homeless Persons",
12+
# "notes" : "Number of homeless persons, in shelter and out of shelter",
13+
# "author" : "Sources: Alexandria Homeless Services Coordinating Committee (HSCC); 2011 Count of Homeless Persons in Metropolitan Washington http://www.mwcog.org/uploads/pub-documents/p15eXlo20110512131909.pdf",
14+
# "url" : "http://www.mwcog.org/uploads/pub-documents/p15eXlo20110512131909.pdf",
15+
# "groups" : "meeting_basic_needs",
16+
#}
17+
18+
#ind2_1_dict = {
19+
# "name" : "median-costs",
20+
# "title" : "Median Owner Costs",
21+
# "group" : "Meeting Basic Needs",
22+
# "notes" : "Median owner costs as percent of income past 12 months",
23+
#}
24+
25+
ind2_3_dict = {
26+
"name" : "affordable-housing",
27+
"title" : "Affordable Housing Availability",
28+
"group" : "Meeting Basic Needs",
29+
"notes" : "Number of housing units available for households earning below 50 or 60 percent of median income",
30+
}
31+
32+
ind2_4_dict = {
33+
"name" : "median-gross-rent",
34+
"title" : "Median Rent",
35+
"group" : "Meeting Basic Needs",
36+
"notes" : "Median gross rent",
37+
}
38+
39+
ind2_5_dict = {
40+
"name" : "foreclosure-by-type",
41+
"title" : "Foreclosure",
42+
"group" : "Meeting Basic Needs",
43+
"notes" : "Number of foreclosures by type of Real Estate",
44+
}
45+
46+
ind2_6_dict = {
47+
"name" : "snap",
48+
"title" : "Food Stamps",
49+
"group" : "Meeting Basic Needs",
50+
"notes" : "Number of SNAP (formerly Food Stamp) participants",
51+
}
52+
53+
ind2_7_dict = {
54+
"name" : "school-lunch-elig",
55+
"title" : "School Lunch",
56+
"group" : "Meeting Basic Needs",
57+
"notes" : "Number of students eligible for free and reduced-price school lunch",
58+
}
59+
60+
#make_pkg(ind2_1_dict)
61+
make_pkg(ind2_3_dict)
62+
make_pkg(ind2_4_dict)
63+
make_pkg(ind2_5_dict)
64+
make_pkg(ind2_6_dict)
65+
make_pkg(ind2_7_dict)

make_pkg.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
import urllib2
3+
import urllib
4+
import json
5+
import pprint
6+
import ckan_api
7+
8+
def make_pkg(data_dict):
9+
10+
# Use json module to dump the dictionary to a string for posting.
11+
data_string = urllib.quote(json.dumps(data_dict))
12+
13+
# Use package_create function to create new dataset.
14+
request = urllib2.Request('http://ckan.codefornova.org/api/3/action/package_create')
15+
16+
# Creating a dataset requires an authorization header.
17+
# Replace *** with API key
18+
request.add_header('Authorization', ckan_api.myapi)
19+
20+
# Make HTTP request.
21+
response = urllib2.urlopen(request, data_string)
22+
assert response.code == 200
23+
24+
# Use the json module to load CKAN's response into a dictionary.
25+
response_dict = json.loads(response.read())
26+
assert response_dict['success'] is True
27+
28+
# create_data returns the created package as its result.
29+
create_package = response_dict['result']
30+
pprint.pprint(create_package)

make_pkg_theme10.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
import urllib2
4+
import urllib
5+
import json
6+
import pprint
7+
import ckan_api
8+
from make_pkg import make_pkg
9+
10+
11+
ind10_1 = {
12+
"name" : "air-quality",
13+
"title" : "Air Quality",
14+
"groups" : [{"name" : "cleanliness-and-beautification"}],
15+
"notes" : "Indicator: Number of “Air Quality Action” days per year. Source: Environmental Quality Commission",
16+
}
17+
18+
ind10_2 = {
19+
"name" : "environmental-health",
20+
"title" : "Environmental Health",
21+
"groups" : [{"name" : "cleanliness-and-beautification"}],
22+
"notes" : "Indicator: Number of complaints to Environmental Health regarding perceived environmental hazards (mold, radon, toxic exposures, etc.) or pests (bedbugs, mosquitoes, ticks etc.). Source: Alexandria Health Department",
23+
}
24+
25+
ind10_3 = {
26+
"name" : "recycling",
27+
"title" : "Recycling",
28+
"groups" : [{"name" : "cleanliness-and-beautification"}],
29+
"notes" : "Indicator: % of solid waste recycled. Source: Environmental Quality Commission",
30+
}
31+
32+
make_pkg(ind10_1)
33+
make_pkg(ind10_2)
34+
make_pkg(ind10_3)

make_pkg_theme11.py

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
import urllib2
4+
import urllib
5+
import json
6+
import pprint
7+
import ckan_api
8+
from make_pkg import make_pkg
9+
10+
11+
ind11_1 = {
12+
"name" : "median-household-income",
13+
"title" : "Median Household Income",
14+
"groups" : [{"name" : "employment-opportunities"}],
15+
"notes" : "Source: 2000 Decennial Census, 2005-2010 1-Year ACS Samples",
16+
}
17+
18+
ind11_2 = {
19+
"name" : "workforce",
20+
"title" : "Workforce",
21+
"groups" : [{"name" : "employment-opportunities"}],
22+
"notes" : "Indicator: % population over 16 in workforce (same as labor force participation). Source: 2005-2010 1-Year ACS Samples",
23+
}
24+
25+
ind11_3 = {
26+
"name" : "poverty",
27+
"title" : "Poverty",
28+
"groups" : [{"name" : "employment-opportunities"}],
29+
"notes" : "Indicator: % population below poverty level. Source: 2000 Decennial Census, 2005-2010 1-Year ACS Samples",
30+
}
31+
32+
ind11_4 = {
33+
"name" : "graduation",
34+
"title" : "On-Time Graduation",
35+
"groups" : [{"name" : "employment-opportunities"}],
36+
"notes" : "Indicator: ACPS High School Graduation Rate. Source: Alexandria City Public Schools",
37+
}
38+
ind11_5 = {
39+
"name" : "unemployment",
40+
"title" : "Unemployment",
41+
"groups" : [{"name" : "employment-opportunities"}],
42+
"notes" : "Indicator: Unemployment at local level. Source: Bureau of Labor Statistics",
43+
}
44+
45+
ind11_6 = {
46+
"name" : "hs-diploma",
47+
"title" : "High School Diploma",
48+
"groups" : [{"name" : "employment-opportunities"}],
49+
"notes" : "Indicator: % adults aged 25 and older with a high school diploma or GED. Source: 2000 Decennial Census, 2005-2010 1-Year ACS Samples",
50+
}
51+
52+
ind11_7 = {
53+
"name" : "retail-occupancy",
54+
"title" : "Retail Occupancy",
55+
"groups" : [{"name" : "employment-opportunities"}],
56+
"notes" : "Indicator: % Retail Occupancy. Source: Alexandria Economic Development Partnership. Contact: Christina Mindrup Robinson, Alexandria Economic Development Partnership, [email protected]",
57+
}
58+
59+
make_pkg(ind11_1)
60+
make_pkg(ind11_2)
61+
make_pkg(ind11_3)
62+
make_pkg(ind11_4)
63+
make_pkg(ind11_5)
64+
make_pkg(ind11_6)
65+
make_pkg(ind11_7)

make_pkg_theme4.py

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
import urllib2
4+
import urllib
5+
import json
6+
import pprint
7+
import ckan_api
8+
from make_pkg import make_pkg
9+
10+
11+
ind4_1 = {
12+
"name" : "pct-adults-w-healthcare",
13+
"title" : "Percent of Adults with Health Coverage",
14+
"groups" : [{"name" : "access-to-health-care"}],
15+
"notes" : "Indicator: % of adults ages 18-64 who currently report having any kind of health care coverage. Source: BRFSS. Question: Do you have any kind of health care coverage, including health insurance, prepaid plans such as HMOs or government plans such as Medicare?",
16+
}
17+
18+
ind4_2 = {
19+
"name" : "num-schip-participants",
20+
"title" : "Number SCHIP Participants",
21+
"groups" : [{"name" : "access-to-health-care"}],
22+
"notes" : "Indicator: # Alexandria's children participating in the federal State Children’s Health Insurance Program (SCHIP). Source: Virginia Department of Health, Division of Health Statistics",
23+
}
24+
25+
ind4_3 = {
26+
"name" : "pct-deferred-care",
27+
"title" : "Percent People Deferring Health Care",
28+
"groups" : [{"name" : "access-to-health-care"}],
29+
"notes" : "Indicator: % of people indicating they needed to see a doctor in the past year and could not due to cost. Source: BRFSS",
30+
}
31+
32+
ind4_4 = {
33+
"name" : "pct-prenatal-care",
34+
"title" : "Percent Women Receiving Prenatal Care",
35+
"groups" : [{"name" : "access-to-health-care"}],
36+
"notes" : "Indicator: % of women who received prenatal care in the first trimester of pregnancy. Source: Virginia Department of Health, Division of Health Statistics. http://www.vdh.state.va.us/epidemiology/DiseasePrevention/DAta/Quarterly/2nd%20Quarter%202011/Table6HIV_Q2.pdf",
37+
}
38+
39+
ind4_5 = {
40+
"name" : "rate-new-hiv",
41+
"title" : "Rate of New HIV Diagnoses",
42+
"groups" : [{"name" : "access-to-health-care"}],
43+
"notes" : "Indicator: The total annual number of newly diagnosed cases of HIV per 100,000 people in the population. Source: Virginia Department of Health, Division of Health Statistics, http://www.vdh.state.va.us/epidemiology/DiseasePrevention/DAta/Quarterly/2nd%20Quarter%202011/Table6HIV_Q2.pdf",
44+
}
45+
46+
ind4_6 = {
47+
"name" : "good-health",
48+
"title" : "Adults Reporting Good to Excellent Health",
49+
"groups" : [{"name" : "access-to-health-care"}],
50+
"notes" : "Indicator: % of adults who rated their health good to excellent. Source: BRFSS",
51+
}
52+
53+
ind4_7 = {
54+
"name" : "flu-shot",
55+
"title" : "Percent Adults Receiving Flu Shot",
56+
"groups" : [{"name" : "access-to-health-care"}],
57+
"notes" : "Indicator: % adults who received seasonal influenza vaccine in past 12 months. Source: BRFSS",
58+
}
59+
60+
ind4_8 = {
61+
"name" : "overweight",
62+
"title" : "Percent Adults Overweight or Obese",
63+
"groups" : [{"name" : "access-to-health-care"}],
64+
"notes" : "Indicator: % of adults overweight or obese in the population. Source: BRFSS",
65+
}
66+
67+
ind4_10 = {
68+
"name" : "heart-mortality",
69+
"title" : "Rate of Heart Disease Mortality",
70+
"groups" : [{"name" : "access-to-health-care"}],
71+
"notes" : "Indicator: Heart Disease Mortality Rate. Source: Virginia Department of Health, Health Profile, Alexandria City, 2000-2009",
72+
}
73+
74+
ind4_11 = {
75+
"name" : "cancer-mortality",
76+
"title" : "Rate of Cancer Mortality",
77+
"groups" : [{"name" : "access-to-health-care"}],
78+
"notes" : "Indicator: Cancer Mortality Rate. Source: Virginia Department of Health, Division of Health Statistics",
79+
}
80+
81+
ind4_12 = {
82+
"name" : "infant-mortality",
83+
"title" : "Rate of Infant Mortality",
84+
"groups" : [{"name" : "access-to-health-care"}],
85+
"notes" : "Indicator: Infant mortality rate per 1,000 live births. Source: Virginia Department of Health, Health Profile, Alexandria City, 2000-2009",
86+
}
87+
88+
ind4_13 = {
89+
"name" : "teen-pregnancy",
90+
"title" : "Rate of Teen Pregnancy",
91+
"groups" : [{"name" : "access-to-health-care"}],
92+
"notes" : "Indicator: Teen Pregnancy Rate (per 1000 girls). Source: Virginia Department of Health, Health Profile, Alexandria City, 2000-2009",
93+
}
94+
95+
make_pkg(ind4_1)
96+
make_pkg(ind4_2)
97+
make_pkg(ind4_3)
98+
make_pkg(ind4_4)
99+
make_pkg(ind4_5)
100+
make_pkg(ind4_6)
101+
make_pkg(ind4_7)
102+
make_pkg(ind4_8)
103+
make_pkg(ind4_10)
104+
make_pkg(ind4_11)
105+
make_pkg(ind4_12)
106+
make_pkg(ind4_13)

make_pkg_theme5.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
import urllib2
4+
import urllib
5+
import json
6+
import pprint
7+
import ckan_api
8+
from make_pkg import make_pkg
9+
10+
11+
ind5_1 = {
12+
"name" : "walk-work",
13+
"title" : "Percent of Residents Walking to Work",
14+
"groups" : [{"name" : "built-environment"}],
15+
"notes" : "Indicator: % of residents walking to work. Source: ACS, 2005-2010, 1-year samples",
16+
}
17+
18+
ind5_2 = {
19+
"name" : "bike-work",
20+
"title" : "Percent of Residents Biking to Work",
21+
"groups" : [{"name" : "built-environment"}],
22+
"notes" : "Indicator: % of residents walking/biking to work. Source: ACS, 2005-2010, 1-year samples",
23+
}
24+
25+
ind5_3 = {
26+
"name" : "tree-canopy",
27+
"title" : "Percent Tree Canopy Coverage",
28+
"groups" : [{"name" : "built-environment"}],
29+
"notes" : "Indicator: % tree canopy coverage. Source: Virginia Department of Health, Health Profile, Alexandria City, 2000-2009",
30+
}
31+
32+
ind5_4 = {
33+
"name" : "shared-use-paths",
34+
"title" : "Shared Use Paths",
35+
"groups" : [{"name" : "built-environment"}],
36+
"notes" : "Indicator: Total miles of designated shared-use paths and bike lanes relative to total street miles (Revised from Strategic Plan Indicator). Source: Carrie Sanders, City of Alexandria ",
37+
}
38+
39+
ind5_6 = {
40+
"name" : "public-transport",
41+
"title" : "Percent of Residents Taking Public Transport to Work",
42+
"groups" : [{"name" : "built-environment"}],
43+
"notes" : "Indicator: % residents who take public transportation to work. Source: ACS 1-Year Sample, Selected Economic Characteristics (DP03)",
44+
}
45+
46+
make_pkg(ind5_1)
47+
make_pkg(ind5_2)
48+
make_pkg(ind5_3)
49+
make_pkg(ind5_4)
50+
make_pkg(ind5_6)

0 commit comments

Comments
 (0)