print("Firefox is still running, we can quit") driver.quit() else: print("Firefox is dead, can't quit. Let's kill the driver") firefox_process.kill() else: print("driver has died") print("alimentando banco de dados") data = np.array([ datahora, mwd, hm0, seapeakdir, seahm0, swellpeakdir, swellhm0, wspd, gust ]) data = data.transpose() df = pd.DataFrame(data) df.columns = [ 'date_time', 'wvdir', 'swvht', 'wvdir_sea', 'swvht_sea', 'wvdir_swell', 'swvht_swell', 'wspd', 'gust' ] station = db.select_station(['institution', 'name'], ['hidromares', 'suape']).id[0] df = df.replace(to_replace=['None', 'NULL', ' ', ''], value=np.nan) df['station_id'] = station db.delete_old_data(df, station) db.insert_new_data(df)
print("Nao ha dados para essa boia") else: result['datahora'] = pd.to_datetime(result.iloc[:, 0:6]) del result['YEAR'] del result['MONTH'] del result['DAY'] del result['HOUR'] del result['MINUTE'] del result['SECOND'] result.columns = [ 'water_level', 'wspd', 'wdir', 'atmp', 'rh', 'dewpt', 'pres', 'date_time' ] result = result.replace(to_replace=['None', 'NULL', ' ', ''], value=np.nan) # for key in result.keys(): # result[key] = result[key].astype(float) station = boias_simcosta['id'][i] result['station_id'] = station db.delete_old_data(result, station) db.insert_new_data(result) print('dados da boia simcosta ' + boias_simcosta['name'][i] + ' inseridos no banco')