Example #1
0
 def __init__(self,rtype,year):
     f = open(IMLSConst.DATA_PATH.format(rtype,year),'r')
     self.records = []
     self.record_dict = {}
     self.rtype = rtype
     self.year = year
     self.fields = IMLSRecordKeys.fields[rtype][year]
     for line in f.readlines():
         rec = IMLSRecord(line,rtype,year)
         self.records.append(rec)
         #this might be specific to puout format, be carful
         if rtype is "puout":
             self.record_dict[rec.lookup("FSCSKEY")+rec.lookup("FSCS_SEQ")] = rec
         else:
             self.record_dict[rec.lookup("FSCSKEY")] = rec
Example #2
0
from imlsrecord import IMLSRecord
from imlsdatafile import IMLSDataFile

#right now this main is just for experimenting
#and playing around with code


if __name__ == "__main__":
    print("sanity check for IMLSRecord")
    fpuout = open("./data/puout/puout2009.txt",'r')
    testObj = IMLSRecord(fpuout.readline(),"puout",2009)
    print("puout data")
    print("Print Name and address for test library")
    print(testObj.lookup("libname"))
    print(testObj.lookup("address"))
    print(testObj.lookup("city"))
    print(testObj.lookup("zip"))
    fpuout.close()

    print("pupld data")
    df = IMLSDataFile('pupld',2009)
    df.to_csv()
    print("2009 csv complete")
    df2 = IMLSDataFile('pupld',2008)
    df2.to_csv()
    print("2008 csv complete")
    df3 = IMLSDataFile('pupld',2007)
    df3.to_csv()
    print("2007 csv complete")
    df4 = IMLSDataFile('pupld',2006)
    df4.to_csv()
Example #3
0
from imlsrecord import IMLSRecord

if __name__ == "__main__":
    print("total closing/year 2005-2009")
    for year in range(2005,2010):
        f = open("./data/puout/puout{0}.txt".format(year),'r')
        total_closed = 0
        branches_closed = 0
        total = 0
        for line in f:
            total += 1
            r = IMLSRecord(line,"puout",year)
            status = r.lookup("statstru")
            if status == "03":
                total_closed += 1
                if r.lookup("c_out_ty") == "BR":
                    branches_closed += 1
        print("{0} {1} {2}".format(year,total_closed,branches_closed))
    print("all done!")