# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# country_region_map_join.py
# Created on: 2019-05-31 18:20:32.00000
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy


# Local variables:
country_regions_shp = "S:\\particulates\\data_processing\\data\\mapping\\country_region_lvl_vars\\country_regions.shp"
cl = "cl"
country_regions_Layer__3_ = cl
country_reg_join_csv = "S:\\particulates\\data_processing\\data\\mapping\\country_region_lvl_vars\\country_reg_join.csv"
country_region_lvl_vars = "S:\\particulates\\data_processing\\data\\mapping\\country_region_lvl_vars"
country_region_lvl_vars_gdb = country_region_lvl_vars
country_region_lvl_vars_gdb__2_ = country_region_lvl_vars_gdb

# Process: Make Feature Layer
try:
    arcpy.Delete_management(in_data=cl)
except Error as e:
    print(e)
arcpy.MakeFeatureLayer_management(country_regions_shp, cl, "", "", "FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;gridcode gridcode VISIBLE NONE;COUNTRY COUNTRY VISIBLE NONE;ISO_CC ISO_CC VISIBLE NONE;CONTINENT CONTINENT VISIBLE NONE;Land_Type Land_Type VISIBLE NONE;Land_Rank Land_Rank VISIBLE NONE;Shape_Leng Shape_Leng VISIBLE NONE;Shape_Area Shape_Area VISIBLE NONE;ctry_r_str ctry_r_str VISIBLE NONE;gpw_v4_nat gpw_v4_nat VISIBLE NONE;region region VISIBLE NONE")

# Process: Add Join
arcpy.AddJoin_management(cl, "ctry_r_str", country_reg_join_csv, "ctry_reg", "KEEP_ALL")

# Process: Create File GDB
try:
    arcpy.Delete_management(in_data=country_region_lvl_vars+"\\country_region_lvl_vars.gdb", data_type="Workspace")
except Error as e:
    print('Could not delete geodatabase')
    print(e)

arcpy.CreateFileGDB_management(country_region_lvl_vars, "country_region_lvl_vars", "CURRENT")

# Process: Feature Class to Geodatabase (multiple)
arcpy.FeatureClassToGeodatabase_conversion("cl", country_region_lvl_vars_gdb+"\\country_region_lvl_vars.gdb")

