Esempio n. 1
0
def parse_city(file_path):
    """Parse input data string from file

    :Parameters:
        -`file_path`: path to txt file
    """
    logger = util.get_logger()
    logger.debug('Reading data from %s' % file_path)
    content = util.read_data_from_file(file_path)
    data_dict = _create_dict_from_txt(content)
    logger.debug('Set information from %s to db' % file_path)
    db_util.set_region_and_city(data_dict)
    logger.debug('Parse information from file %s complete success' % file_path)
Esempio n. 2
0
def parse_district(file_path, city_id):
    """Parse input data string from file

    :Parameters:
        -`file_path`: path to txt file
        -`city_id`: id city in db
    """
    logger = util.get_logger()
    logger.debug('Reading data from %s' % file_path)
    content = util.read_data_from_file(file_path)
    data_dict = _create_dict_from_txt(content)
    logger.debug('Set information from %s to db' % file_path)
    db_util.set_district_and_street(data_dict, city_id)
    logger.debug('Parse information from file %s complete success' % file_path)