Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed absolute path to ../data #19

Merged
merged 2 commits into from
Jan 29, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 47 additions & 7 deletions analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,55 @@ def clean_water(directory='/Users/thoughtworker/chicago-river-sewage/data/',file
data=pd.read_csv(directory+file, na_values='na')
np.savetxt(file, data,fmt='%s', delimiter=",")

def cso():
directory='/Users/thoughtworker/chicago-river-sewage/data/'
cso_file='cso_events_timestamped.csv'
def cso(directory='/Users/thoughtworker/chicago-river-sewage/data/', file='cso_events_timestamped.csv', file1='ssmma_mwrd_merge_cleanedup.csv'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Machine-specific paths make it difficult for others to use. Just data/ would work here instead, no?

readdata= pd.read_csv(directory+file1, na_values='na')
loc=list(readdata['TARP Connection'])
lat=list(readdata['LAT_DEC'])
lng=list(readdata['LON_CONV'])
latitude,longitude={},{}
for key, val in zip(loc, lat):
latitude[key]=val
for key, val in zip(loc,lng):
longitude[key]= val
#print len(latitude), len(longitude)
ct=0
fw=open('jnk.csv','w')
fw1=open('nocoord.csv','w')
with open(directory+file,"r") as f:
for line in f:
lsplit=line.split(",")
if len(lsplit)==4 and "(" not in lsplit[0]:
try:
print>>fw, '%s,%s,%s,%s,%s'%(lsplit[0], lsplit[-2],lsplit[-1], latitude[lsplit[0]],longitude[lsplit[0]])
ct+=1
except KeyError:
print>>fw1, '%s,%s,%s,%s,%s'%(lsplit[0], lsplit[-2],lsplit[-1], 'nan','nan')
ct+=1
if len(lsplit)!=4 and "(" in lsplit[0]:
tmp=line.split("),")[0].split("(")[1].split(",")[0]
try:
print>>fw, '%s,%s,%s,%s,%s'%(tmp,lsplit[-2],lsplit[-1],latitude[tmp],longitude[tmp])
ct+=1
except KeyError:
print>>fw1, '%s,%s,%s,%s,%s'%(tmp,lsplit[-2],lsplit[-1],'nan','nan')
ct+=1
if len(lsplit)!=4 and "(" not in lsplit[0]:
try:
print>>fw, '%s,%s,%s,%s,%s'%(lsplit[0], lsplit[-2],lsplit[-1], latitude[lsplit[0]],longitude[lsplit[0]])
ct+=1
except KeyError:
print>>fw1, '%s,%s,%s,%s,%s'%(lsplit[0], lsplit[-2],lsplit[-1], 'nan','nan')
ct+=1
print ct
fw.close()



cso_data= pd.read_csv(directory+cso_file, na_values='na')
print cso_data.shape



if __name__=="__main__":
mwrd()
#cso()
#mwrd()
cso()
#clean_water()
#cso_loc()
Loading