Commit 183c5ce9 authored by Craig Earley's avatar Craig Earley
Browse files

added the most basic code

parent 7003fc1c
UPDATE calls SET longitude = (-1 * longitude) WHERE longitude > 0;
UPDATE calls SET our_complaint = '10-11' WHERE complaint LIKE '10-11%';
UPDATE calls SET our_complaint = '10-10' WHERE complaint = '10-10';
UPDATE calls SET our_complaint = '' WHERE complaint = '';
UPDATE calls SET our_complaint = '10-14' WHERE complaint = '10-14';
UPDATE calls SET our_complaint = '10-15' WHERE complaint LIKE '10-15%';
UPDATE calls SET our_complaint = '10-16' WHERE complaint LIKE '10-16%';
UPDATE calls SET our_complaint = '10-31' WHERE complaint LIKE '10-31%';
UPDATE calls SET our_complaint = '10-37' WHERE complaint LIKE '10-37%';
UPDATE calls SET our_complaint = '10-50' WHERE complaint LIKE '10-50%';
UPDATE calls SET our_complaint = '10-52' WHERE complaint LIKE '10-52%';
UPDATE calls SET our_complaint = '10-53' WHERE complaint LIKE '10-53%';
UPDATE calls SET our_complaint = '10-58' WHERE complaint LIKE '10-58%';
UPDATE calls SET our_complaint = '10-59' WHERE complaint LIKE '10-59%';
UPDATE calls SET our_complaint = '10-70' WHERE complaint LIKE '10-70%';
UPDATE calls SET our_complaint = '10-97' WHERE complaint LIKE '10-97%';
CREATE TEMPORARY TABLE temptable (call character(20), abb character(5), name character(50));
\copy temptable (call, abb, name) from '/home/datascience/departmentsdispatched.csv' with (format csv);
\copy temptable (call, abb, name) from '/cluster/home/datascience/departmentsdispatched.csv' with (format csv);
CREATE TEMPORARY TABLE temptable (call character(20), abb character(5), name character(50));
\copy temptable (call, abb, name) from '/cluster/home/datascience/departmentsdispatched.csv' with (format csv);
insert into test (agency_abbrev, agency_name) select abb, name from temptable;
DROP TABLE temptable;
\copy call_details FROM '/cluster/home/datascience/departmentsdispatched.csv' WITH DELIMITER (',') CSV;
\copy call_details FROM '/cluster/home/datascience/departmentsdispatched.csv' WITH DELIMITER (',') CSV;
\copy call_details FROM '/cluster/home/datascience/departmentsdispatched.csv' CSV;
create table test as select * from calls;
alter table test add our_city char(20);
update test set city = 'Richmond' where city = 'RCHMOND';
update test set our_city = 'Richmond' where lower(city) like '%ichm%';
update test set our_city = 'Richmond' where lower(city) = 'rchmond';
update test set our_city = 'Randolph county', out_of_jurisdiction = true where lower(city) like 'rando%';
update test set our_city = 'Rush county', out_of_jurisdiction = true where lower(city)='rushville';
update test set our_city = 'Randolph county', out_of_jurisdiction = true where lower(city)='ridgeville';
update test set our_city = 'Greens Fork' where lower(city)='greens%';
update test set our_city = 'Greens Fork' where lower(city) like 'greens%';
update test set our_city = 'Fayette county', out_of_jurisdiction = true where lower(city) like 'fayette%';
update test set our_city = 'Fayette county', out_of_jurisdiction = true where lower(city) like 'connersville%';
update test set our_city = 'Randolph county', out_of_jurisdiction = true where lower(city) = 'union city';
update test set our_city = 'Union county', out_of_jurisdiction = true where lower(city) = 'union co';
update test set our_city = 'Union county', out_of_jurisdiction = true where lower(city) = 'union twp';
update test set our_city = 'Fayette county', out_of_jurisdiction = true where lower(city) like 'connorsville%';
update test set our_city = 'Ohio', out_of_jurisdiction = true where lower(city) like 'new p%';
update test set our_city = 'Henry county', out_of_jurisdiction = true where lower(city) like 'new l%';
update test set our_city = 'Henry county', out_of_jurisdiction = true where lower(city) like 'new c%';
update test set our_city = 'Hagerstown' where lower(city) like 'hage%';
update test set our_city = 'Greens Fork' where lower(city) like 'green fork';
update test set our_city = 'Cambridge city' where lower(city) like 'cambridge%';
update test set our_city = 'Johnson county' where lower(city) like 'franklin%';
update test set our_city = 'Franklin county' where lower(city) = 'whitewater';
update test set out_of_jurisdiction = true where lower(city) like 'franklin%';
update test set out_of_jurisdiction = true where lower(city) = 'whitewater';
update test set our_city = 'Marion county', out_of_jurisdiction = true where lower(city) = 'indianapolis';
update test set our_city = 'Boston' where lower(city) like 'bos%';
update test set our_city = 'Henry county', out_of_jurisdiction = true where lower(city) = 'henry co';
update test set our_city = 'Randolph county', out_of_jurisdiction = true where lower(city) like 'white r%';
update test set our_city = 'Randolph county', out_of_jurisdiction = true where lower(city) like 'win%';
update test set our_city = 'Abington' where lower(city) like 'abing%';
update test set our_city = 'Bethel' where lower(city) like 'bethel%';
update test set our_city = 'Centerville' where lower(city) like 'center%';
update test set our_city = 'Dublin' where lower(city) = 'dublin';
update test set our_city = 'Mt Auburn' where lower(city) = 'mt auburn';
update test set our_city = 'Webster' where lower(city) = 'webster';
update test set our_city = 'Richmond' where lower(city) = 'q';
update test set our_city = 'Richmond' where lower(city) like 'cause%';
update test set our_city = 'Muncie' where lower(city) = 'sweetwater';
update test set our_city = 'Centerville' where lower(city) = 'cnet';
update test set our_city = 'Economy' where lower(city) = 'econd';
update test set our_city = 'Richmond' where lower(address) = '18 n 22nd st';
\copy (select (address || ',' || our_city) as c_add from test where latitude is null and complaint_category <> 'o') to 'lat_long_find.csv' with csv delimiter ',';
\copy (select address, our_city from test where latitude is null and complaint_category <> 'o') to 'lat_long_find.csv' with csv delimiter ',';
......@@ -5,6 +5,9 @@ This is the code and some other documentation for the 911 calls project.
# Key Files
This is where we are going to list key files.
* file_edit.py: edits the file
* final_map.py: creates the final visualization
* 911_history.sql: an SQL history file
# Project Members
......
read_file = open(your_file,'r+')
i = 0
all_lines = read_file.readlines()
read_file.seek(0)
for line in all_lines:
line = line.rstrip()
if i == 0:
line += ",State"
print(line, file=read_file)
else:
line += ", IN"
print(line, file=read_file)
i+=1
read_file.truncate()
read_file.close()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment