#import csv, urllib2
#
## get the data
#U = urllib2.urlopen('ftp://voteview.com/dtaord/hou112kh.ord')
#f = file('hou112kh.ord','w')
#f.write(U.read())
#f.close()
#
## read the data into a list
#with open('hou112kh.ord', 'rb') as csvfile:
#    reader = csv.reader(csvfile, delimiter=',')
#    vote_data = [row for row in reader] 
#
## parse the data
#cdict = {}
#for q in vote_data:
#    qq = q[0]
#    name = qq[25:36].strip()
#    party = qq[20:23]
#    state = qq[12:19]
#    vdata = [int(x) for x in qq[36:].strip()]
#    cdict[name] = [vdata,party,state] 
#
## convert votes to numbers
#def modv(v):
#    q = []
#    for i in range(len(v)):
#        s = v[i]
#        if s in [1,2,3]:
#            q.append(1.0)
#        elif s in [4,5,6]:
#            q.append(-1.0)
#        else:
#            q.append(0.0)
#    #q = vector(q)
#    return q 
#sks = sorted(cdict.keys())
#vmat = [modv(cdict[q][0]) for q in sks]
#
#names = open('names.txt', 'wb')
#parties = open('parties.txt', 'wb')
#votes = open('votes.txt','wb')
#
#for name in cdict:
#	names.write("%s\n"%name)
#	parties.write("%s\n"%cdict[name][1])
#	voteCode = modv(cdict[name][0])
#	for v in voteCode:				
#		votes.write("%s, "%v)
#	votes.write("\n")
#
#names.close()
#parties.close()
#votes.close()
#
#
