Exemplo n.º 1
0
    def extract_city_data(self):
        dest = State.file_prefix + "Aggregate"
        dir = Dir(dest)
        if dir.exists() is False:
            dir.create_if_needed()

        f = open(dest + "/aggr.csv", "ab")
        writer = csv.writer(f, delimiter=",")
        for alpha in self._alpha:
            data_path = State.file_prefix + self._abbrv + "/City"
            for root, dirs, files in os.walk(data_path):
                for file in files:
                    this_city = City(self._abbrv, self._state, file)
                    this_city.extract_and_publish(writer)
        f.close()
Exemplo n.º 2
0
    def extract_city_data(self):
        dest = State.file_prefix + 'Aggregate'
        dir = Dir(dest)
        if dir.exists() is False:
            dir.create_if_needed()

        f = open(dest + '/aggr.csv', 'ab')
        writer = csv.writer(f, delimiter=',')
        for alpha in self._alpha:
            data_path = State.file_prefix + self._abbrv + '/City'
            for root, dirs, files in os.walk(data_path):
                for file in files:
                    this_city = City(self._abbrv, self._state, file)
                    this_city.extract_and_publish(writer)
        f.close()
Exemplo n.º 3
0
    def fetch_cities_in_state(self):
        for alpha in self._alpha:
            url = State.url_prefix + self._abbrv + "/" + alpha
            dest = State.file_prefix + self._abbrv + "/" + alpha
            print "downloading state (%s), url (%s), state (%s)" % (self._state, url, dest)
            dir = Dir(dest)
            if dir.exists() is False:
                dir.create_if_needed()

            # check if data is present
            data_file = File(dest + "/file")
            if data_file.exists() is True:
                print "data present for state %s, %s" % (self._state, alpha)
                continue

            download = Download(url, dest + "/file")
            download.download()
Exemplo n.º 4
0
    def fetch_cities_in_state(self):
        for alpha in self._alpha:
            url = State.url_prefix + self._abbrv + '/' + alpha
            dest = State.file_prefix + self._abbrv + '/' + alpha
            print 'downloading state (%s), url (%s), state (%s)' % (
                self._state, url, dest)
            dir = Dir(dest)
            if dir.exists() is False:
                dir.create_if_needed()

            # check if data is present
            data_file = File(dest + '/file')
            if data_file.exists() is True:
                print 'data present for state %s, %s' % (self._state, alpha)
                continue

            download = Download(url, dest + '/file')
            download.download()
Exemplo n.º 5
0
    def fetch_cities_data(self):
        dest = State.file_prefix + self._abbrv + "/City"
        dir = Dir(dest)
        if dir.exists() is False:
            dir.create_if_needed()

        for alpha in self._alpha:
            data = File(State.file_prefix + self._abbrv + "/" + alpha + "/file")
            if data.exists() is True:
                # parse and get a list of cities
                print "parsing city data for (%s, %s)" % (self._state, alpha)
                cities = CityParser(self._abbrv, data)
                for c in cities.parse():
                    this_city = City(self._abbrv, State.state_map[self._abbrv], c)
                    try:
                        this_city.fetch_data()
                    except Exception:
                        print "error data for (%s, %s)" % (self._state, alpha)
            else:
                print "...... no data for %s, %s" % (self._abbrv, alpha)
Exemplo n.º 6
0
    def fetch_cities_data(self):
        dest = State.file_prefix + self._abbrv + '/City'
        dir = Dir(dest)
        if dir.exists() is False:
            dir.create_if_needed()

        for alpha in self._alpha:
            data = File(State.file_prefix + self._abbrv + '/' + alpha +
                        '/file')
            if data.exists() is True:
                # parse and get a list of cities
                print 'parsing city data for (%s, %s)' % (self._state, alpha)
                cities = CityParser(self._abbrv, data)
                for c in cities.parse():
                    this_city = City(self._abbrv, State.state_map[self._abbrv],
                                     c)
                    try:
                        this_city.fetch_data()
                    except Exception:
                        print 'error data for (%s, %s)' % (self._state, alpha)
            else:
                print '...... no data for %s, %s' % (self._abbrv, alpha)