In [1]:
import pandas as pd
from sqlalchemy import create_engine

In [40]:
BT_all = pd.read_csv('/users/jdlara/Documents/Box Sync/EPIC-Biomass/Biomass data/BillionTonUpdateForestResources/KDF_Frst_LOGT.dat', encoding='UTF-8', delimiter = ',', dtype = {'fcode':str})
BT_all = BT_all.fillna(0)
FIPS_all = pd.read_csv('/users/jdlara/Documents/Box Sync/EPIC-Biomass/Biomass data/BillionTonUpdateForestResources/fips_codes2.csv', encoding='UTF-8', dtype = {'State FIPS Code':str,'County FIPS Code':str})
FIPS_all['fcode'] = FIPS_all[['State FIPS Code', 'County FIPS Code']].apply(lambda x: ''.join(x), axis=1)
FIPS_all = FIPS_all.loc[FIPS_all['Entity Description'] == 'County']
FIPS_all = FIPS_all.set_index('fcode')

In [41]:
df_join = BT_all.join(FIPS_all, on = 'fcode')

In [2]:
engine = create_engine('postgresql+pg8000://jdlara:Amadeus-2010@switch-db2.erg.berkeley.edu:5432/apl_cec?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory', isolation_level="AUTOCOMMIT")

In [46]:
df_join.to_sql('KDF_Frst_LOGT', engine, schema='Billion_TON', if_exists = 'replace')

In [5]:
engine_source = create_engine('postgresql+pg8000://jdlara:Bario-140@switch-db2.erg.berkeley.edu:5432/switch_gis?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory')
engine_dest = create_engine('postgresql+pg8000://jdlara:Bario-140@switch-db2.erg.berkeley.edu:5432/APL_CEC?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory')
df_r = pd.read_sql_query('select * from ventyx_may_2012.maj_road_polyline',engine_source)
df_subs = pd.read_sql_query('select * from ventyx_may_2012.e_buses_wecc_point',engine_source)
df_subs = df_subs.set_index('gid')
df_counties = df_counties.set_index('gid')
df_counties.to_sql('Counties', engine, schema='General_GIS_DATA', if_exists = 'replace')
#df_subs.to_sql('WECC_Substations', engine, schema='General_GIS_DATA', if_exists = 'replace')

In [3]:
engine_source = create_engine('postgresql+pg8000://jdlara:Amadeus-2010@switch-db2.erg.berkeley.edu:5432/switch_gis?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory')

In [4]:
df_roads = pd.read_sql_query('select * from ventyx_may_2012.maj_road_polyline',engine_source)

In [5]:
df_roads = df_roads.set_index('gid')

In [6]:
df_roads.to_sql('maj_road_polyline', engine, schema='General_GIS_DATA', if_exists = 'replace')

In [2]:
BT_all = pd.read_csv('/Users/jdlara/Documents/Box Sync/EPIC-Biomass/Data sept 25/LEMMA_parallel_CRMORT.csv', encoding='UTF-8', delimiter = ',')

In [ ]:


In [3]:
engine = create_engine('postgresql+pg8000://jdlara:Amadeus-2010@switch-db2.erg.berkeley.edu:5432/apl_cec?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory', isolation_level="AUTOCOMMIT")

In [4]:
BT_all.to_sql('lemma_crmort', engine, schema='lemma', if_exists = 'replace',chunksize=10000)

In [ ]: