result['email'] = {'value': ''} if 'website' not in result: result['website'] = {'value': ''} LOGGER.info(f'Getting embassy data for {result["country"]["value"]}') DB.insert_or_update('embassies', result['country']['value'], result['city']['value'], result['operator']['value'], result['type']['value'], result['phone']['value'], result['email']['value'], result['website']['value']) LOGGER.success( f'Successfully entered embassy information for {result["country"]["value"]}' ) except Exception as error_msg: LOGGER.error( f'Could not get embassy data for {result["country"]["value"]} because of the following error: {error_msg}' ) pass for result in consulates_results["results"]["bindings"]: try: if 'city' not in result: result['city'] = {'value': ''} if 'operator' not in result: result['operator'] = {'value': ''} if 'phone' not in result: result['phone'] = {'value': ''} if 'email' not in result: result['email'] = {'value': ''} if 'website' not in result: result['website'] = {'value': ''}
homicideRate_object = social_data[social_data.index.str.startswith('Intentional homicide rate')] homicideRate = next(iter(homicideRate_object), 'no match') LOGGER.success(f'Following currency data was retrieved: {homicideRate}') # Pick specific dataframe that will always be the fourth index data_table_env = data_tables[4] LOGGER.info(f'Parsing returned following dataframe: {data_table_env}') # Get latest year latest_year_env = data_table_env.columns[-1] LOGGER.info(f'Parsing returned following year: {latest_year_env}') # Get data of latest year env_data = data_table_env.iloc[:,-1] LOGGER.info(f'Parsing returned following year data: {env_data}') sanitation_object = env_data[env_data.index.str.startswith('Pop. using improved sanitation')] sanitation = next(iter(sanitation_object), 'no match') LOGGER.success(f'Following currency data was retrieved: {sanitation}') water_object = env_data[env_data.index.str.startswith('Pop. using improved drinking water')] water = next(iter(water_object), 'no match') LOGGER.success(f'Following currency data was retrieved: {water}') LOGGER.info('Inserting data into database.') DB.insert_or_update('un', country, lifeExpectancy, infantMortality, nbOfPhysicians, homicideRate, sanitation, water) except Exception as error_msg: LOGGER.error(f'Could not get currency data for {country} because of the following error: {error_msg}') pass
# Get total recovered total_recovered = int( float(data_frame.loc[iso_dict[iso], 'TotalRecovered'].replace(',', ''))) LOGGER.info( f'Parsing returned following total recovered: {total_recovered}') # Get active cases active_cases = int( float(data_frame.loc[iso_dict[iso], 'ActiveCases'].replace(',', ''))) LOGGER.info(f'Parsing returned following active cases: {active_cases}') # Get serious critical serious_critical = int( float(data_frame.loc[iso_dict[iso], 'Serious,Critical'].replace(',', ''))) LOGGER.info( f'Parsing returned following total recovered: {serious_critical}') LOGGER.info('Inserting data into database.') DB.insert_or_update('covid19', iso, str(total_cases), str(new_cases), str(total_deaths), str(new_deaths), str(total_recovered), str(active_cases), str(serious_critical)) except Exception as error_msg: LOGGER.error( f'Could not parse data for {iso} because of the following error: {error_msg}' )