This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sshtunnel import SSHTunnelForwarder | |
| from sqlalchemy.orm import sessionmaker | |
| from sqlalchemy import create_engine | |
| from sqlalchemy import inspect | |
| import pandas as pd | |
| class Postgresql_connect(object): | |
| def __init__(self, pgres_host, pgres_port, db, ssh, ssh_user, ssh_host, ssh_pkey): | |
| # SSH Tunnel Variables | |
| self.pgres_host = pgres_host |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| todays_date = date.today().strftime("%m_%d_%Y") | |
| json_df.to_csv(f'/path/to/directory/Georgia_Extract_({todays_date}).csv',index=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| json_df[json_df.columns] = json_df[json_df.columns].replace({'"':'',']':'','}':''},regex=True) | |
| for col_name in col_names: | |
| json_df[col_name] = json_df[col_name].str.split(":",expand=True)[1] | |
| json_df = json_df.sort_values(by=['Test Date','Measure','County'], ascending=[False,False,True]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| json_df = pd.DataFrame(json_list,columns=["new"]) | |
| json_df = json_df["new"].str.split(",", expand = True) | |
| col_names = ['Measure','County','Test Date','Positives','Death Count','Cumulative Positives', | |
| 'Cumulative Deaths','Moving Average (Cases)','Moving Average (Deaths)'] | |
| json_df.columns = col_names |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| json_list = json_extract.split("},{") | |
| json_list = [sub.replace("{", "") for sub in json_list] | |
| json_list = ["["+sub+"]" for sub in json_list] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| json_extract = response_text.split("{t.exports=JSON.parse('[")[1].split("]\')},function(t)")[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sesh = requests.Session() | |
| response = sesh.get('https://ga-covid19.ondemand.sas.com/static/js/main.js') | |
| response_text = response.text |
NewerOlder