text:
diccionario_indicadores = Dict("Defunciones Generales" => "1002000030", "Nacimientos" => "1002000026", "Población de 5 años y más hablante de lengua indígena" => "1005000039", "Porcentaje de hombres" => "6207020032", "Porcentaje de mujeres" => "6207020033", "Edad mediana" => "1002000010", "Población total" => "1002000001", "Densidad de población" => "3105001001")

diccionario_estados = Dict("Aguascalientes" => "0001", "Baja California" => "0002", "Baja California Sur" => "0003", "Campeche" => "0004", "Chiapas" => "0007", "Chihuahua" => "0008", "Ciudad de México" => "0009", "Coahuila de Zaragoza" => "0005", "Colima" => "0006", "Durango" => "0010", "Guanajuato" => "0011", "Guerrero" => "0012", "Hidalgo" => "0013", "Jalisco" => "0014", "Michoacán de Ocampo" => "0016", "Morelos" => "0017", "México" => "0015", "Nayarit" => "0018", "Nuevo León" => "0019", "Oaxaca" => "0020", "Puebla" => "0021", "Querétaro" => "0022", "Quintana Roo" => "0023", "San Luis Potosí" => "0024", "Sinaloa" => "0025", "Sonora" => "0026", "Tabasco" => "0027", "Tamaulipas" => "0028", "Tlaxcala" => "0029", "Veracruz de Ignacio de la Llave" => "0030", "Yucatán" => "0031", "Zacatecas" => "0032")

diccionario_municipios = Array{Dict{String, String}, 2}(undef, 32, 1);

diccionario_municipios[parse(Int64, get(diccionario_estados, "Aguascalientes", "Not founded"))] = Dict("Total estatal" => "", "Aguascalientes" => "0001", "Asientos" => "0002", "Calvillo" => "0003", "Cosío" => "0004", "El Llano" => "0010", "Jesús María" => "0005", "Pabellón de Arteaga" => "0006", "Rincón de Romos" => "0007", "San Francisco de los Romo" => "0011", "San José de Gracia" => "0008", "Tepezalá" => "0009");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Baja California", "Not founded"))] = Dict("Total estatal" => "", "Ensenada" => "0001", "Mexicali" => "0002", "Playas de Rosarito" => "0005", "San Quintín" => "0006", "Tecate" => "0003", "Tijuana" => "0004");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Baja California Sur", "Not founded"))] = Dict("Total estatal" => "", "Comondú" => "0001", "La Paz" => "0003", "Loreto" => "0009", "Los Cabos" => "0008", "Mulegé" => "0002");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Campeche", "Not founded"))] = Dict("Total estatal" => "", "Calakmul" => "0010", "Calkiní" => "0001", "Campeche" => "0002", "Candelaria" => "0011", "Carmen" => "0003", "Champotón" => "0004", "Escárcega" => "0009", "Hecelchakán" => "0005", "Hopelchén" => "0006", "Palizada" => "0007", "Seybaplaya" => "0012", "Tenabo" => "0008");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Coahuila de Zaragoza", "Not founded"))] = Dict("Total estatal" => "", "Abasolo" => "0001", "Acuña" => "0002", "Allende" => "0003", "Arteaga" => "0004", "Candela" => "0005", "Castaños" => "0006", "Cuatro Ciénegas" => "0007", "Escobedo" => "0008", "Francisco I. Madero" => "0009", "Frontera" => "0010", "General Cepeda" => "0011", "Guerrero" => "0012", "Hidalgo" => "0013", "Jiménez" => "0014", "Juárez" => "0015", "Lamadrid" => "0016", "Matamoros" => "0017", "Monclova" => "0018", "Morelos" => "0019", "Múzquiz" => "0020", "Nadadores" => "0021", "Nava" => "0022", "Ocampo" => "0023", "Parras" => "0024", "Piedras Negras" => "0025", "Progreso" => "0026", "Ramos Arizpe" => "0027", "Sabinas" => "0028", "Sacramento" => "0029", "Saltillo" => "0030", "San Buenaventura" => "0031", "San Juan de Sabinas" => "0032", "San Pedro" => "0033", "Sierra Mojada" => "0034", "Torreón" => "0035", "Viesca" => "0036", "Villa Unión" => "0037", "Zaragoza" => "0038");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Chiapas", "Not founded"))] = Dict("Total estatal" => "", "Acacoyagua" => "0001", "Acala" => "0002", "Acapetahua" => "0003", "Altamirano " => "0004", "Amatán" => "0005", "Amatenango de la Frontera" => "0006", "Amatenango del Valle " => "0007", "Angel Albino Corzo" => "0008", "Arriaga" => "0009", "Bejucal de Ocampo" => "0010", "Bella Vista" => "0011", "Berriozábal" => "0012", "Bochil" => "0013", "El Bosque " => "0014", "Cacahoatán" => "0015", "Catazajá" => "0016", "Cintalapa" => "0017", "Coapilla" => "0018", "Comitán de Domínguez" => "0019", "La Concordia" => "0020", "Copainalá" => "0021", "Chalchihuitán " => "0022", "Chamula " => "0023", "Chanal " => "0024", "Chapultenango" => "0025", "Chenalhó " => "0026", "Chiapa de Corzo" => "0027", "Chiapilla" => "0028", "Chicoasén " => "0029", "Chicomuselo" => "0030", "Chilón " => "0031", "Escuintla" => "0032", "Francisco León" => "0033", "Frontera Comalapa" => "0034", "Frontera Hidalgo" => "0035", "La Grandeza " => "0036", "Huehuetán" => "0037", "Huixtán" => "0038", "Huitiupán" => "0039", "Huixtla" => "0040", "La Independencia" => "0041", "Ixhuatán" => "0042", "Ixtacomitán" => "0043", "Ixtapa" => "0044", "Ixtapangajoya " => "0045", "Jiquipilas" => "0046", "Jitotol " => "0047", "Juárez" => "0048", "Larráinzar " => "0049", "La Libertad" => "0050", "Mapastepec" => "0051", "Las Margaritas" => "0052", "Mazapa de Madero" => "0053", "Mazatán" => "0054", "Metapa " => "0055", "Mitontic " => "0056", "Motozintla" => "0057", "Nicolás Ruíz " => "0058", "Ocosingo" => "0059", "Ocotepec" => "0060", "Ocozocoautla de Espinosa" => "0061", "Ostuacán" => "0062", "Osumacinta " => "0063", "Oxchuc" => "0064", "Palenque" => "0065", "Pantelhó " => "0066", "Pantepec" => "0067", "Pichucalco" => "0068", "Pijijiapan" => "0069", "El Porvenir" => "0070", "Villa Comaltitlán" => "0071", "Pueblo Nuevo Solistahuacán" => "0072", "Rayón" => "0073", "Reforma" => "0074", "Las Rosas" => "0075", "Sabanilla " => "0076", "Salto de Agua" => "0077", "San Cristóbal de las Casas" => "0078", "San Fernando" => "0079", "Siltepec" => "0080", "Simojovel " => "0081", "Sitalá " => "0082", "Socoltenango" => "0083", "Solosuchiapa" => "0084", "Soyaló" => "0085", "Suchiapa" => "0086", "Suchiate" => "0087", "Sunuapa " => "0088", "Tapachula" => "0089", "Tapalapa " => "0090", "Tapilula" => "0091", "Tecpatán" => "0092", "Tenejapa " => "0093", "Teopisca" => "0094", "Tila " => "0096", "Tonalá" => "0097", "Totolapa" => "0098", "La Trinitaria" => "0099", "Tumbalá " => "0100", "Tuxtla Gutiérrez" => "0101", "Tuxtla Chico" => "0102", "Tuzantán" => "0103", "Tzimol" => "0104", "Unión Juárez" => "0105", "Venustiano Carranza" => "0106", "Villa Corzo" => "0107", "Villaflores" => "0108", "Yajalón" => "0109", "San Lucas" => "0110", "Zinacantán " => "0111", "San Juan Cancuc " => "0112", "Aldama " => "0113", "Benemérito de las Américas" => "0114", "Maravilla Tenejapa " => "0115", "Marqués de Comillas" => "0116", "Montecristo de Guerrero" => "0117", "San Andrés Duraznal " => "0118", "Santiago el Pinar " => "0119");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Colima", "Not founded"))] = Dict("Total estatal" => "", "Armería" => "0001", "Colima" => "0002", "Cómala" => "0003", "Coquimatlan" => "0004", "Cuauhtémoc" => "0005", "Ixtlahuacan" => "0006", "Manzanillo" => "0007", "Minatitlán" => "0008", "Tecoman" => "0009", "Villa de Álvarez" => "0010");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Durango", "Not founded"))] = Dict("Total estatal" => "", "Cantatlan" => "0001", "Canelas" => "0002", "Constó de Comonfort" => "0003", "Cuencame" => "0004", "Durango" => "0005", "El Oro" => "0018", "General Simón Bolívar" => "0006", "Guadalupe Victoria" => "0008", "Guanacevi" => "0009", "Gómez Palacio" => "0007", "Hidalgo" => "0010", "Inde" => "0011", "Lerdo" => "0012", "Mapimí" => "0013", "Mezquital" => "0014", "Nazas" => "0015", "Nombre de Dios" => "0016", "Nuevo Ideal" => "0039", "Ocampo" => "0017", "Otaez" => "0019", "Peñon Blanco" => "0021", "Poanas" => "0022", "Pueblo Nuevo" => "0023", "Pánuco de Coronado" => "0020", "Rodeo" => "0024", "San Bernardo" => "0025", "San Dimas" => "0026", "San Juan de Guadalupe" => "0027", "San Juan del Río" => "0028", "San Luis de Cordero" => "0029", "San Pedro del Gallo" => "0030", "Santa Clara" => "0031", "Santiago Papasquiaro" => "0032", "Suchil" => "0033", "Tamazula" => "0034", "Tapehuanes" => "0035", "Tlahualilo" => "0036", "Tópica" => "0037", "Vicente Guerrero" => "0038");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Guanajuato", "Not founded"))] = Dict("Total estatal" => "", "Abasolo" => "0001", "Acámbaro" => "0002", "Apaseo el Alto" => "0004", "Apaseo el Grande" => "0005", "Atarjea" => "0006", "Celaya" => "0007", "Comonfort" => "0009", "Coroneo" => "0010", "Cortázar" => "0011", "Cueramaro" => "0012", "Doctor Mora" => "0013", "Dolores Hidalgo Cuna de la Independencia Nacional" => "0014", "Guanajuato" => "0015", "Huaminaro" => "0016", "Irapuato" => "0017", "Jaral del Progreso" => "0018", "Jerecuaro" => "0019", "Leon" => "0020", "Manuel doblado" => "0008", "Morleon" => "0021", "Ocampo" => "0022", "Pueblo Nuevo" => "0024", "Puso rima del Rincón" => "0025", "Penjamo" => "0023", "Romita" => "0026", "Salamanca" => "0027", "Salvatierra" => "0028", "San Diego de la Union" => "0029", "San Felipe" => "0030", "San Francisco del Rincón" => "0031", "San Jose Iturbide" => "0032", "San Luis de la Paz" => "0033", "San Miguel de Allende" => "0003", "Santa Catarina" => "0034", "Santa Cruz de Juventino Rosas" => "0035", "Santiago Maravatio" => "0036", "Silao" => "0037", "Tarandacuao" => "0038", "Tarimoro" => "0039", "Tierra Blanca" => "0040", "Uriangato" => "0041", "Valle de Santiago" => "0042", "Victoria" => "0043", "Villagran" => "0044", "Xichu" => "0045", "Yuriria" => "0046");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Guerrero", "Not founded"))] = Dict("Total estatal" => "", "Acapulco de Juárez" => "0001", "Acatepec" => "0076", "Ahuacoutzingo" => "0002", "Ajuchitlan del Progreso" => "0003", "Alcozauca de Guerrero" => "0004", "Alpoyeca" => "0005", "Apaxtla" => "0006", "Arcelia" => "0007", "Atennago del Río" => "0008", "Atlamajalcingo del Monte" => "0009", "Atlixtac" => "0010", "Atoyac de Alvarez" => "0011", "Ayutla de los Libres" => "0012", "Azoyu" => "0013", "Benito Juárez" => "0014", "Buena vista de Cuellar" => "0015", "Chilapa de Alvarez" => "0028", "Chilpancingo de los Bravos" => "0029", "Coahuayutla de José Maria Izazaga" => "0016", "Cochoapa el Grande" => "0078", "Cocula" => "0017", "Cópala" => "0018", "Coapalillo" => "0019", "Copanatoyac" => "0020", "Coyuca de Benitez" => "0021", "Coyuca de Catalan" => "0022", "Cuajinicuilapa" => "0023", "Cualac" => "0024", "Cuautepec" => "0025", "Cuetzala del progreso" => "0026", "Cutzamala de Pinzon" => "0027", "Eduardo Neri" => "0075", "Florencio Villarreal" => "0030", "General Canuto A. Neri" => "0031", "General Heliodoro Castillo" => "0032", "Huamuxtitlan" => "0033", "Huitzuco de Los Figueroa" => "0034", "Iguala de la Independencia" => "0035", "Igualapa" => "0036", "Iliatenco" => "0081", "Ixcateopan de Cuauhtémoc" => "0037", "José Joaquín de Herrera" => "0079", "Juan R. Escudero" => "0039", "Juchitan" => "0080", "La Unión de Isidoro Montes de Oca" => "0068", "Leonardo Bravo" => "0040", "Malinaltepec" => "0041", "Márquelia" => "0077", "Metlatonoc" => "0043", "Mochitlan" => "0044", "Mártir de Cuilapan" => "0042", "Olinala" => "0045", "Ometepec" => "0046", "Pedro Ascencio Alquisiras" => "0047", "Petatlan" => "0048", "Pilcaya" => "0049", "Pungarabato" => "0050", "Quechultenango" => "0051", "San Luis Acatlan" => "0052", "San Marcos" => "0053", "San Miguel Totolapan" => "0054", "Taxco de Alarcón" => "0055", "Tecoanapa" => "0056", "Teloloapan" => "0058", "Tepecoacuilco de Trujano" => "0059", "Tetipac" => "0060", "Tixtla de Guerrero" => "0061", "Tlacoachistlahuaca" => "0062", "Tlacoapa" => "0063", "Tlalchapa" => "0064", "Tlalixtaquilla de Maldonado" => "0065", "Tapa de Comonfort" => "0066", "Tlapehuala" => "0067", "Tecpan de Galeana" => "0057", "Xalpatlahuac" => "0069", "Xochihuehuetlan" => "0070", "Xochistlahuaca" => "0071", "Zapotitlan tablas" => "0072", "Zihuatanejo de Azuela" => "0038", "Zirandano" => "0073", "Zitlala" => "0074");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Hidalgo", "Not founded"))] = Dict("Total estatal" => "","Acatlán"=>"0001","Acaxochitlán"=>"0002","Actopan"=>"0003","Agua Blanca de Iturbide"=>"0004","Ajacuba"=>"0005","Alfajayucan"=>"0006","Almoloya"=>"0007","Apan"=>"0008","Atitalaquia"=>"0010","Atlapexco"=>"0011","Atotonilco de Tula"=>"0013","Atotonilco el Grande"=>"0012","Calnali"=>"0014","Cardonal"=>"0015","Chapantongo"=>"0017","Chapulhuacán"=>"0018","Chilcuautla"=>"0019","Cuautepec de Hinojosa"=>"0016","El Arenal"=>"0009","Eloxochitlán"=>"0020","Emiliano Zapata"=>"0021","Epazoyucan"=>"0022","Francisco I. Madero"=>"0023","Huasca de Ocampo"=>"0024","Huautla"=>"0025","Huazalingo"=>"0026","Huehuetla"=>"0027","Huejutla de Reyes"=>"0028","Huichapan"=>"0029","Ixmiquilpan"=>"0030","Jacala de Ledezma"=>"0031","Jaltocán"=>"0032","Juárez Hidalgo"=>"0033","La Misión"=>"0040","Lolotla"=>"0034","Metepec"=>"0035","Metztitlán"=>"0037","Mineral de la Reforma"=>"0051","Mineral del Chico"=>"0038","Mineral del Monte"=>"0039","Mixquiahuala de Juárez"=>"0041","Molango de Escamilla"=>"0042","Nicolás Flores"=>"0043","Nopala de Villagrán"=>"0044","Omitlán de Juárez"=>"0045","Pachuca de Soto"=>"0048","Pacula"=>"0047","Pisaflores"=>"0049","Progreso de Obregón"=>"0050","San Agustín Metzquititlán"=>"0036","San Agustín Tlaxiaca"=>"0052","San Bartolo Tutotepec"=>"0053","San Felipe Orizatlán"=>"0046","San Salvador"=>"0054","Santiago de Anaya"=>"0055","Santiago Tulantepec de Lugo Guerrero"=>"0056","Singuilucan"=>"0057","Tasquillo"=>"0058","Tecozautla"=>"0059","Tenango de Doria"=>"0060","Tepeapulco"=>"0061","Tepehuacán de Guerrero"=>"0062","Tepeji del Río de Ocampo"=>"0063","Tepetitlán"=>"0064","Tetepango"=>"0065","Tezontepec de Aldama"=>"0067","Tianguistengo"=>"0068","Tizayuca"=>"0069","Tlahuelilpan"=>"0070","Tlahuiltepa"=>"0071","Tlanalapa"=>"0072","Tlanchinol"=>"0073","Tlaxcoapan"=>"0074","Tolcayuca"=>"0075","Tula de Allende"=>"0076","Tulancingo de Bravo"=>"0077","Villa de Tezontepec"=>"0066","Xochiatipan"=>"0078","Xochicoatlán"=>"0079","Yahualica"=>"0080","Zacualtipán de Ángeles"=>"0081","Zapotlán de Juárez"=>"0082","Zempoala"=>"0083","Zimapán"=>"0084");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Ciudad de México", "Not founded"))] = Dict("Total estatal" => "", "Azcapotzalco" => "0002", "Coyoacán" => "0003", "Cuajimalpa de Morelos" => "0004", "Gustavo A. Madero" => "0005", "Iztacalco" => "0006", "Iztapalapa" => "0007", "La Magdalena Contreras" => "0008", "Milpa Alta" => "0009", "Álvaro Obregón" => "0010", "Tláhuac" => "0011", "Tlalpan" => "0012", "Xochimilco" => "0013", "Benito Juárez" => "0014", "Cuauhtémoc" => "0015", "Miguel Hidalgo" => "0016", "Venustiano Carranza" => "0017");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Chihuahua", "Not founded"))] = Dict("Total estatal" => "", "Apozol" => "0001", "Apulco" => "0002", "Atolinga" => "0003", "Benito Juárez" => "0004", "Calera" => "0005", "Cañitas de Felipe Pescador" => "0006", "Concepción del Oro" => "0007", "Cuauhtémoc" => "0008", "Chalchihuites" => "0009", "Fresnillo" => "0010", "Trinidad García de la Cadena" => "0011", "Genaro Codina" => "0012", "General Enrique Estrada" => "0013", "General Francisco R. Murguía" => "0014", "El Plateado de Joaquín Amaro" => "0015", "General Pánfilo Natera" => "0016", "Guadalupe" => "0017", "Huanusco" => "0018", "Jalpa" => "0019", "Jerez" => "0020", "Jiménez del Teul" => "0021", "Juan Aldama" => "0022", "Juchipila" => "0023", "Loreto" => "0024", "Luis Moya" => "0025", "Mazapil" => "0026", "Melchor Ocampo" => "0027", "Mezquital del Oro" => "0028", "Miguel Auza" => "0029", "Momax " => "0030", "Monte Escobedo" => "0031", "Morelos" => "0032", "Moyahua de Estrada" => "0033", "Nochistlán de Mejía" => "0034", "Noria de Ángeles" => "0035", "Ojocaliente" => "0036", "Pánuco" => "0037", "Pinos" => "0038", "Río Grande" => "0039", "Sain Alto" => "0040", "El Salvador" => "0041", "Sombrerete" => "0042", "Susticacán " => "0043", "Tabasco" => "0044", "Tepechitlán" => "0045", "Tepetongo" => "0046", "Teúl de González Ortega" => "0047", "Tlaltenango de Sánchez Román" => "0048", "Valparaíso" => "0049", "Vetagrande" => "0050", "Villa de Cos" => "0051", "Villa García" => "0052", "Villa González Ortega" => "0053", "Villa Hidalgo" => "0054", "Villanueva" => "0055", "Zacatecas" => "0056", "Trancoso" => "0057", "Santa María de la Paz" => "0058");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Jalisco", "Not founded"))] = Dict("Total estatal" => "", "Acatic" => "0001", "Acatlán de Juárez" => "0002", "Ahualulco de Mercado" => "0003", "Amacueca" => "0004", "Amatitán" => "0005", "Ameca" => "0006", "Arandas" => "0008", "Atemajac de Brizuela" => "0010", "Atengo" => "0011", "Atenguillo " => "0012", "Atotonilco el Alto" => "0013", "Atoyac" => "0014", "Autlán de Navarro" => "0015", "Ayotlán" => "0016", "Ayutla" => "0017", "Bolaños" => "0019", "Cabo Corrientes" => "0020", "Cañadas de Obregón " => "0117", "Casimiro Castillo" => "0021", "Chapala" => "0030", "Chimaltitán " => "0031", "Chiquilistlán" => "0032", "Cihuatlán" => "0022", "Cocula" => "0024", "Colotlán" => "0025", "Concepción de Buenos Aires" => "0026", "Cuautitlán de García Barragán" => "0027", "Cuautla " => "0028", "Cuquío" => "0029", "Degollado" => "0033", "Ejutla " => "0034", "El Arenal" => "0009", "El Grullo" => "0037", "El Limón" => "0054", "El Salto" => "0070", "Encarnación de Díaz" => "0035", "Etzatlán" => "0036", "Gómez Farías" => "0079", "Guachinango " => "0038", "Guadalajara" => "0039", "Hostotipaquillo" => "0040", "Huejúcar" => "0041", "Huejuquilla el Alto" => "0042", "Ixtlahuacán de los Membrillos" => "0044", "Ixtlahuacán del Río" => "0045", "Jalostotitlán" => "0046", "Jamay" => "0047", "Jesús María" => "0048", "Jilotlán de los Dolores" => "0049", "Jocotepec" => "0050", "Juanacatlán" => "0051", "Juchitlán" => "0052", "La Barca" => "0018", "La Huerta" => "0043", "La Manzanilla de la Paz " => "0057", "Lagos de Moreno" => "0053", "Magdalena" => "0055", "Mascota" => "0058", "Mazamitla" => "0059", "Mexticacán" => "0060", "Mezquitic " => "0061", "Mixtlán " => "0062", "Ocotlán" => "0063", "Ojuelos de Jalisco" => "0064", "Pihuamo" => "0065", "Poncitlán" => "0066", "Puerto Vallarta" => "0067", "Quitupan" => "0069", "San Cristóbal de la Barranca " => "0071", "San Diego de Alejandría" => "0072", "San Gabriel" => "0113", "San Ignacio Cerro Gordo" => "0125", "San Juan de los Lagos" => "0073", "San Juanito de Escobedo" => "0007", "San Julián" => "0074", "San Marcos " => "0075", "San Martín de Bolaños " => "0076", "San Martín Hidalgo" => "0077", "San Miguel el Alto" => "0078", "San Pedro Tlaquepaque" => "0098", "San Sebastián del Oeste" => "0080", "Santa María de los Ángeles " => "0081", "Santa María del Oro " => "0056", "Sayula" => "0082", "Tala" => "0083", "Talpa de Allende" => "0084", "Tamazula de Gordiano" => "0085", "Tapalpa" => "0086", "Tecalitlán" => "0087", "Techaluta de Montenegro " => "0089", "Tecolotlán" => "0088", "Tenamaxtlán" => "0090", "Teocaltiche" => "0091", "Teocuitatlán de Corona" => "0092", "Tepatitlán de Morelos" => "0093", "Tequila" => "0094", "Teuchitlán" => "0095", "Tizapán el Alto" => "0096", "Tlajomulco de Zúñiga" => "0097", "Tolimán" => "0099", "Tomatlán" => "0100", "Tonalá" => "0101", "Tonaya" => "0102", "Tonila" => "0103", "Totatiche" => "0104", "Tototlán" => "0105", "Tuxcacuesco " => "0106", "Tuxcueca" => "0107", "Tuxpan" => "0108", "Unión de San Antonio" => "0109", "Unión de Tula" => "0110", "Valle de Guadalupe" => "0111", "Valle de Juárez" => "0112", "Villa Corona" => "0114", "Villa Guerrero" => "0115", "Villa Hidalgo" => "0116", "Villa Purificación" => "0068", "Yahualica de González Gallo" => "0118", "Zacoalco de Torres" => "0119", "Zapopan" => "0120", "Zapotiltic" => "0121", "Zapotitlán de Vadillo" => "0122", "Zapotlán del Rey" => "0123", "Zapotlán el Grande" => "0023", "Zapotlanejo" => "0124");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Michoacán de Ocampo", "Not founded"))] = Dict("Total estatal" => "", "Acuitzio" => "0001", "Aguililla" => "0002", "Álvaro Obregón" => "0003", "Angamacutiro" => "0004", "Angangueo" => "0005", "Apatzingán" => "0006", "Aporo " => "0007", "Aquila" => "0008", "Ario" => "0009", "Arteaga" => "0010", "Briseñas" => "0011", "Buenavista" => "0012", "Carácuaro" => "0013", "Charapan" => "0021", "Charo" => "0022", "Chavinda" => "0023", "Cherán" => "0024", "Chilchota" => "0025", "Chinicuila " => "0026", "Chucándiro" => "0027", "Churintzio" => "0028", "Churumuco" => "0029", "Coahuayana" => "0014", "Coalcomán de Vázquez Pallares" => "0015", "Coeneo" => "0016", "Cojumatlán de Régules" => "0074", "Contepec" => "0017", "Copándaro" => "0018", "Cotija" => "0019", "Cuitzeo" => "0020", "Ecuandureo" => "0030", "Epitacio Huerta" => "0031", "Erongarícuaro" => "0032", "Gabriel Zamora" => "0033", "Hidalgo" => "0034", "Huandacareo" => "0036", "Huaniqueo" => "0037", "Huetamo" => "0038", "Huiramba" => "0039", "Indaparapeo" => "0040", "Irimbo" => "0041", "Ixtlán" => "0042", "Jacona" => "0043", "Jiménez" => "0044", "Jiquilpan" => "0045", "José Sixto Verduzco" => "0113", "Juárez" => "0046", "Jungapeo" => "0047", "La Huacana" => "0035", "La Piedad" => "0069", "Lagunillas" => "0048", "Lázaro Cárdenas" => "0052", "Los Reyes" => "0075", "Madero" => "0049", "Maravatío" => "0050", "Marcos Castellanos" => "0051", "Morelia" => "0053", "Morelos" => "0054", "Múgica" => "0055", "Nahuatzen" => "0056", "Nocupétaro" => "0057", "Nuevo Parangaricutiro" => "0058", "Nuevo Urecho" => "0059", "Numarán" => "0060", "Ocampo" => "0061", "Pajacuarán" => "0062", "Panindícuaro" => "0063", "Paracho" => "0065", "Parácuaro" => "0064", "Pátzcuaro" => "0066", "Penjamillo" => "0067", "Peribán" => "0068", "Purépero" => "0070", "Puruándiro" => "0071", "Queréndaro" => "0072", "Quiroga" => "0073", "Sahuayo" => "0076", "Salvador Escalante" => "0079", "San Lucas" => "0077", "Santa Ana Maya" => "0078", "Senguio" => "0080", "Susupuato" => "0081", "Tacámbaro" => "0082", "Tancítaro" => "0083", "Tangamandapio" => "0084", "Tangancícuaro" => "0085", "Tanhuato" => "0086", "Taretan" => "0087", "Tarímbaro" => "0088", "Tepalcatepec" => "0089", "Tingambato" => "0090", "Tingüindín" => "0091", "Tiquicheo de Nicolás Romero" => "0092", "Tlalpujahua" => "0093", "Tlazazalca" => "0094", "Tocumbo" => "0095", "Tumbiscatío" => "0096", "Turicato" => "0097", "Tuxpan" => "0098", "Tuzantla" => "0099", "Tzintzuntzan" => "0100", "Tzitzio" => "0101", "Uruapan" => "0102", "Venustiano Carranza" => "0103", "Villamar" => "0104", "Vista Hermosa" => "0105", "Yurécuaro" => "0106", "Zacapu" => "0107", "Zamora" => "0108", "Zináparo " => "0109", "Zinapécuaro" => "0110", "Ziracuaretiro" => "0111", "Zitácuaro" => "0112");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Morelos", "Not founded"))] = Dict("Total estatal" => "", "Amacuzac" => "0001", "Atlatlahucan" => "0002", "Axochiapan" => "0003", "Ayala" => "0004", "Coatlán del Río" => "0005", "Cuautla" => "0006", "Cuernavaca" => "0007", "Emiliano Zapata" => "0008", "Huitzilac" => "0009", "Jantetelco" => "0010", "Jiutepec" => "0011", "Jojutla" => "0012", "Jonacatepec" => "0013", "Mazatepec" => "0014", "Miacatlán" => "0015", "Ocuituco" => "0016", "Puente de Ixtla" => "0017", "Temixco" => "0018", "Tepalcingo" => "0019", "Tepoztlán" => "0020", "Tetecala" => "0021", "Tetela del Volcán" => "0022", "Tlalnepantla" => "0023", "Tlaltizapán de Zapata" => "0024", "Tlaquiltenango" => "0025", "Tlayacapan" => "0026", "Totolapan" => "0027", "Xochitepec" => "0028", "Yautepec" => "0029", "Yecapixtla" => "0030", "Zacatepec" => "0031", "Zacualpan de Amilpas" => "0032", "Temoac" => "0033");

diccionario_municipios[parse(Int64, get(diccionario_estados, "México", "Not founded"))] = Dict("Total estatal" => "", "Acambay de Ruíz Castañeda" => "0001", "Acolman" => "0002", "Aculco" => "0003", "Almoloya de Alquisiras" => "0004", "Almoloya de Juárez" => "0005", "Almoloya del Río" => "0006", "Amanalco" => "0007", "Amatepec" => "0008", "Amecameca" => "0009", "Apaxco" => "0010", "Atenco" => "0011", "Atizapán" => "0012", "Atizapán de Zaragoza" => "0013", "Atlacomulco" => "0014", "Atlautla" => "0015", "Axapusco" => "0016", "Ayapango" => "0017", "Calimaya" => "0018", "Capulhuac" => "0019", "Coacalco de Berriozábal" => "0020", "Coatepec Harinas" => "0021", "Cocotitlán" => "0022", "Coyotepec" => "0023", "Cuautitlán" => "0024", "Chalco" => "0025", "Chapa de Mota" => "0026", "Chapultepec" => "0027", "Chiautla" => "0028", "Chicoloapan" => "0029", "Chiconcuac" => "0030", "Chimalhuacán" => "0031", "Donato Guerra" => "0032", "Ecatepec de Morelos" => "0033", "Ecatzingo" => "0034", "Huehuetoca" => "0035", "Hueypoxtla" => "0036", "Huixquilucan" => "0037", "Isidro Fabela" => "0038", "Ixtapaluca" => "0039", "Ixtapan de la Sal" => "0040", "Ixtapan del Oro" => "0041", "Ixtlahuaca" => "0042", "Xalatlaco" => "0043", "Jaltenco" => "0044", "Jilotepec" => "0045", "Jilotzingo" => "0046", "Jiquipilco" => "0047", "Jocotitlán" => "0048", "Joquicingo" => "0049", "Juchitepec" => "0050", "Lerma" => "0051", "Malinalco" => "0052", "Melchor Ocampo" => "0053", "Metepec" => "0054", "Mexicaltzingo" => "0055", "Morelos" => "0056", "Naucalpan de Juárez" => "0057", "Nezahualcóyotl" => "0058", "Nextlalpan" => "0059", "Nicolás Romero" => "0060", "Nopaltepec" => "0061", "Ocoyoacac" => "0062", "Ocuilan" => "0063", "El Oro" => "0064", "Otumba" => "0065", "Otzoloapan" => "0066", "Otzolotepec" => "0067", "Ozumba" => "0068", "Papalotla" => "0069", "La Paz" => "0070", "Polotitlán" => "0071", "Rayón" => "0072", "San Antonio la Isla" => "0073", "San Felipe del Progreso" => "0074", "San Martín de las Pirámides" => "0075", "San Mateo Atenco" => "0076", "San Simón de Guerrero" => "0077", "Santo Tomás" => "0078", "Soyaniquilpan de Juárez" => "0079", "Sultepec" => "0080", "Tecámac" => "0081", "Tejupilco" => "0082", "Temamatla" => "0083", "Temascalapa" => "0084", "Temascalcingo" => "0085", "Temascaltepec" => "0086", "Temoaya" => "0087", "Tenancingo" => "0088", "Tenango del Aire" => "0089", "Tenango del Valle" => "0090", "Teoloyucán" => "0091", "Teotihuacán" => "0092", "Tepetlaoxtoc" => "0093", "Tepetlixpa" => "0094", "Tepotzotlán" => "0095", "Tequixquiac" => "0096", "Texcaltitlán" => "0097", "Texcalyacac" => "0098", "Texcoco" => "0099", "Tezoyuca" => "0100", "Tianguistenco" => "0101", "Timilpan" => "0102", "Tlalmanalco" => "0103", "Tlalnepantla de Baz" => "0104", "Tlatlaya" => "0105", "Toluca" => "0106", "Tonatico" => "0107", "Tultepec" => "0108", "Tultitlán" => "0109", "Valle de Bravo" => "0110", "Villa de Allende" => "0111", "Villa del Carbón" => "0112", "Villa Guerrero" => "0113", "Villa Victoria" => "0114", "Xonacatlán" => "0115", "Zacazonapan" => "0116", "Zacualpan" => "0117", "Zinacantepec" => "0118", "Zumpahuacán" => "0119", "Zumpango" => "0120", "Cuautitlán Izcalli" => "0121", "Valle de Chalco Solidaridad" => "0122", "Luvianos" => "0123", "San José del Rincón" => "0124", "Tonanitla" => "0125");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Nayarit", "Not founded"))] = Dict("Total estatal" => "", "Acaponeta" => "0001", "Ahuacatlán" => "0002", "Amatlán de Cañas" => "0003", "Compostela" => "0004", "Huajicori" => "0005", "Ixtlán del Río" => "0006", "Jala" => "0007", "Xalisco" => "0008", "Del Nayar " => "0009", "Rosamorada" => "0010", "Ruíz" => "0011", "San Blas" => "0012", "San Pedro Lagunillas" => "0013", "Santa María del Oro" => "0014", "Santiago Ixcuintla" => "0015", "Tecuala" => "0016", "Tepic" => "0017", "Tuxpan" => "0018", "La Yesca" => "0019", "Bahía de Banderas" => "0020");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Nuevo León", "Not founded"))] = Dict("Total estatal" => "", "Abasolo " => "0001", "Agualeguas " => "0002", "Allende" => "0004", "Anáhuac" => "0005", "Apodaca" => "0006", "Aramberri" => "0007", "Bustamante " => "0008", "Cadereyta Jiménez" => "0009", "Cerralvo" => "0011", "China" => "0013", "Ciénega de Flores" => "0012", "Doctor Arroyo" => "0014", "Doctor Coss " => "0015", "Doctor González " => "0016", "El Carmen" => "0010", "Galeana" => "0017", "García" => "0018", "General Bravo" => "0020", "General Escobedo" => "0021", "General Terán" => "0022", "General Treviño " => "0023", "General Zaragoza" => "0024", "General Zuazua" => "0025", "Guadalupe" => "0026", "Hidalgo" => "0047", "Higueras " => "0028", "Hualahuises" => "0029", "Iturbide " => "0030", "Juárez" => "0031", "Lampazos de Naranjo" => "0032", "Linares" => "0033", "Los Aldamas " => "0003", "Los Herreras " => "0027", "Los Ramones" => "0042", "Marín" => "0034", "Melchor Ocampo " => "0035", "Mier y Noriega" => "0036", "Mina" => "0037", "Montemorelos" => "0038", "Monterrey" => "0039", "Parás " => "0040", "Pesquería" => "0041", "Rayones " => "0043", "Sabinas Hidalgo" => "0044", "Salinas Victoria" => "0045", "San Nicolás de los Garza" => "0046", "San Pedro Garza García" => "0019", "Santa Catarina" => "0048", "Santiago" => "0049", "Vallecillo " => "0050", "Villaldama" => "0051");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Oaxaca", "Not founded"))] = Dict("Total estatal" => "", "Abejones " => "0001", "Acatlán de Pérez Figueroa" => "0002", "Asunción Cacalotepec " => "0003", "Asunción Cuyotepeji " => "0004", "Asunción Ixtaltepec" => "0005", "Asunción Nochixtlán" => "0006", "Asunción Ocotlán " => "0007", "Asunción Tlacolulita " => "0008", "Ayotzintepec" => "0009", "El Barrio de la Soledad" => "0010", "Calihualá " => "0011", "Candelaria Loxicha " => "0012", "Ciénega de Zimatlán " => "0013", "Ciudad Ixtepec" => "0014", "Coatecas Altas " => "0015", "Coicoyán de las Flores " => "0016", "La Compañía " => "0017", "Concepción Buenavista " => "0018", "Concepción Pápalo " => "0019", "Constancia del Rosario " => "0020", "Cosolapa" => "0021", "Cosoltepec " => "0022", "Cuilápam de Guerrero" => "0023", "Cuyamecalco Villa de Zaragoza " => "0024", "Chahuites" => "0025", "Chalcatongo de Hidalgo" => "0026", "Chiquihuitlán de Benito Juárez " => "0027", "Heroica Ciudad de Ejutla de Crespo" => "0028", "Eloxochitlán de Flores Magón " => "0029", "El Espinal" => "0030", "Tamazulápam del Espíritu Santo" => "0031", "Fresnillo de Trujano" => "0032", "Guadalupe Etla " => "0033", "Guadalupe de Ramírez " => "0034", "Guelatao de Juárez" => "0035", "Guevea de Humboldt" => "0036", "Mesones Hidalgo " => "0037", "Villa Hidalgo " => "0038", "Heroica Ciudad de Huajuapan de León" => "0039", "Huautepec " => "0040", "Huautla de Jiménez" => "0041", "Ixtlán de Juárez" => "0042", "Heroica Ciudad de Juchitán de Zaragoza" => "0043", "Loma Bonita" => "0044", "Magdalena Apasco" => "0045", "Magdalena Jaltepec " => "0046", "Santa Magdalena Jicotlán " => "0047", "Magdalena Mixtepec " => "0048", "Magdalena Ocotlán " => "0049", "Magdalena Peñasco " => "0050", "Magdalena Teitipac " => "0051", "Magdalena Tequisistlán" => "0052", "Magdalena Tlacotepec " => "0053", "Magdalena Zahuatlán " => "0054", "Mariscala de Juárez " => "0055", "Mártires de Tacubaya " => "0056", "Matías Romero Avendaño " => "0057", "Mazatlán Villa de Flores " => "0058", "Miahuatlán de Porfirio Díaz" => "0059", "Mixistlán de la Reforma " => "0060", "Monjas " => "0061", "Natividad " => "0062", "Nazareno Etla " => "0063", "Nejapa de Madero" => "0064", "Ixpantepec Nieves " => "0065", "Santiago Niltepec" => "0066", "Oaxaca de Juárez" => "0067", "Ocotlán de Morelos" => "0068", "La Pe " => "0069", "Pinotepa de Don Luis" => "0070", "Pluma Hidalgo " => "0071", "San José del Progreso" => "0072", "Putla Villa de Guerrero" => "0073", "Santa Catarina Quioquitani " => "0074", "Reforma de Pineda " => "0075", "La Reforma" => "0076", "Reyes Etla " => "0077", "Rojas de Cuauhtémoc " => "0078", "Salina Cruz" => "0079", "San Agustín Amatengo " => "0080", "San Agustín Atenango " => "0081", "San Agustín Chayuco " => "0082", "San Agustín de las Juntas" => "0083", "San Agustín Etla " => "0084", "San Agustín Loxicha " => "0085", "San Agustín Tlacotepec " => "0086", "San Agustín Yatareni " => "0087", "San Andrés Cabecera Nueva " => "0088", "San Andrés Dinicuiti " => "0089", "San Andrés Huaxpaltepec" => "0090", "San Andrés Huayápam " => "0091", "San Andrés Ixtlahuaca " => "0092", "San Andrés Lagunas " => "0093", "San Andrés Nuxiño " => "0094", "San Andrés Paxtlán " => "0095", "San Andrés Sinaxtla" => "0096", "San Andrés Solaga " => "0097", "San Andrés Teotilálpam " => "0098", "San Andrés Tepetlapa " => "0099", "San Andrés Yaá " => "0100", "San Andrés Zabache " => "0101", "San Andrés Zautla " => "0102", "San Antonino Castillo Velasco" => "0103", "San Antonino el Alto " => "0104", "San Antonino Monte Verde" => "0105", "San Antonio Acutla " => "0106", "San Antonio de la Cal" => "0107", "San Antonio Huitepec " => "0108", "San Antonio Nanahuatípam " => "0109", "San Antonio Sinicahua " => "0110", "San Antonio Tepetlapa" => "0111", "San Baltazar Chichicápam " => "0112", "San Baltazar Loxicha " => "0113", "San Baltazar Yatzachi el Bajo " => "0114", "San Bartolo Coyotepec" => "0115", "San Bartolomé Ayautla " => "0116", "San Bartolomé Loxicha " => "0117", "San Bartolomé Quialana " => "0118", "San Bartolomé Yucuañe " => "0119", "San Bartolomé Zoogocho " => "0120", "San Bartolo Soyaltepec " => "0121", "San Bartolo Yautepec " => "0122", "San Bernardo Mixtepec " => "0123", "San Blas Atempa" => "0124", "San Carlos Yautepec" => "0125", "San Cristóbal Amatlán " => "0126", "San Cristóbal Amoltepec " => "0127", "San Cristóbal Lachirioag " => "0128", "San Cristóbal Suchixtlahuaca " => "0129", "San Dionisio del Mar" => "0130", "San Dionisio Ocotepec" => "0131", "San Dionisio Ocotlán " => "0132", "San Esteban Atatlahuca " => "0133", "San Felipe Jalapa de Díaz " => "0134", "San Felipe Tejalápam" => "0135", "San Felipe Usila " => "0136", "San Francisco Cahuacuá " => "0137", "San Francisco Cajonos " => "0138", "San Francisco Chapulapa " => "0139", "San Francisco Chindúa " => "0140", "San Francisco del Mar" => "0141", "San Francisco Huehuetlán" => "0142", "San Francisco Ixhuatán" => "0143", "San Francisco Jaltepetongo " => "0144", "San Francisco Lachigoló " => "0145", "San Francisco Logueche " => "0146", "San Francisco Nuxaño " => "0147", "San Francisco Ozolotepec " => "0148", "San Francisco Sola " => "0149", "San Francisco Telixtlahuaca" => "0150", "San Francisco Teopan " => "0151", "San Francisco Tlapancingo " => "0152", "San Gabriel Mixtepec " => "0153", "San Ildefonso Amatlán " => "0154", "San Ildefonso Sola " => "0155", "San Ildefonso Villa Alta " => "0156", "San Jacinto Amilpas" => "0157", "San Jacinto Tlacotepec " => "0158", "San Jerónimo Coatlán " => "0159", "San Jerónimo Silacayoapilla " => "0160", "San Jerónimo Sosola " => "0161", "San Jerónimo Taviche " => "0162", "San Jerónimo Tecóatl " => "0163", "San Jorge Nuchita " => "0164", "San José Ayuquila " => "0165", "San José Chiltepec" => "0166", "San José del Peñasco " => "0167", "San José Estancia Grande " => "0168", "San José Independencia " => "0169", "San José Lachiguiri " => "0170", "San José Tenango " => "0171", "San Juan Achiutla " => "0172", "San Juan Atepec " => "0173", "Ánimas Trujano " => "0174", "San Juan Bautista Atatlahuca" => "0175", "San Juan Bautista Coixtlahuaca" => "0176", "San Juan Bautista Cuicatlán" => "0177", "San Juan Bautista Guelache" => "0178", "San Juan Bautista Jayacatlán" => "0179", "San Juan Bautista Lo de Soto" => "0180", "San Juan Bautista Suchitepec" => "0181", "San Juan Bautista Tlacoatzintepec" => "0182", "San Juan Bautista Tlachichilco" => "0183", "San Juan Bautista Tuxtepec" => "0184", "San Juan Cacahuatepec" => "0185", "San Juan Cieneguilla" => "0186", "San Juan Coatzóspam" => "0187", "San Juan Colorado" => "0188", "San Juan Comaltepec" => "0189", "San Juan Cotzocón" => "0190", "San Juan Chicomezúchil" => "0191", "San Juan Chilateca" => "0192", "San Juan del Estado" => "0193", "San Juan del Río" => "0194", "San Juan Diuxi" => "0195", "San Juan Evangelista Analco " => "0196", "San Juan Guelavía" => "0197", "San Juan Guichicovi" => "0198", "San Juan Ihualtepec" => "0199", "San Juan Juquila Mixes" => "0200", "San Juan Juquila Vijanos" => "0201", "San Juan Lachao" => "0202", "San Juan Lachigalla" => "0203", "San Juan Lajarcia" => "0204", "San Juan Lalana" => "0205", "San Juan de los Cués" => "0206", "San Juan Mazatlán" => "0207", "San Juan Mixtepec" => "0208", "San Juan Mixtepec" => "0209", "San Juan Ñumí" => "0210", "San Juan Ozolotepec" => "0211", "San Juan Petlapa" => "0212", "San Juan Quiahije" => "0213", "San Juan Quiotepec" => "0214", "San Juan Sayultepec" => "0215", "San Juan Tabaá" => "0216", "San Juan Tamazola" => "0217", "San Juan Teita" => "0218", "San Juan Teitipac" => "0219", "San Juan Tepeuxila" => "0220", "San Juan Teposcolula" => "0221", "San Juan Yaeé " => "0222", "San Juan Yatzona " => "0223", "San Juan Yucuita " => "0224", "San Lorenzo" => "0225", "San Lorenzo Albarradas " => "0226", "San Lorenzo Cacaotepec" => "0227", "San Lorenzo Cuaunecuiltitla " => "0228", "San Lorenzo Texmelúcan " => "0229", "San Lorenzo Victoria " => "0230", "San Lucas Camotlán " => "0231", "San Lucas Ojitlán " => "0232", "San Lucas Quiaviní " => "0233", "San Lucas Zoquiápam " => "0234", "San Luis Amatlán " => "0235", "San Marcial Ozolotepec " => "0236", "San Marcos Arteaga " => "0237", "San Martín de los Cansecos " => "0238", "San Martín Huamelúlpam " => "0239", "San Martín Itunyoso " => "0240", "San Martín Lachilá " => "0241", "San Martín Peras " => "0242", "San Martín Tilcajete " => "0243", "San Martín Toxpalan " => "0244", "San Martín Zacatepec " => "0245", "San Mateo Cajonos " => "0246", "Capulálpam de Méndez " => "0247", "San Mateo del Mar " => "0248", "San Mateo Yoloxochitlán " => "0249", "San Mateo Etlatongo " => "0250", "San Mateo Nejápam " => "0251", "San Mateo Peñasco " => "0252", "San Mateo Piñas " => "0253", "San Mateo Río Hondo " => "0254", "San Mateo Sindihui " => "0255", "San Mateo Tlapiltepec " => "0256", "San Melchor Betaza " => "0257", "San Miguel Achiutla " => "0258", "San Miguel Ahuehuetitlán" => "0259", "San Miguel Aloápam " => "0260", "San Miguel Amatitlán" => "0261", "San Miguel Amatlán " => "0262", "San Miguel Coatlán " => "0263", "San Miguel Chicahua " => "0264", "San Miguel Chimalapa" => "0265", "San Miguel del Puerto" => "0266", "San Miguel del Río " => "0267", "San Miguel Ejutla " => "0268", "San Miguel el Grande " => "0269", "San Miguel Huautla " => "0270", "San Miguel Mixtepec " => "0271", "San Miguel Panixtlahuaca " => "0272", "San Miguel Peras " => "0273", "San Miguel Piedras " => "0274", "San Miguel Quetzaltepec" => "0275", "San Miguel Santa Flor " => "0276", "Villa Sola de Vega" => "0277", "San Miguel Soyaltepec" => "0278", "San Miguel Suchixtepec " => "0279", "Villa Talea de Castro " => "0280", "San Miguel Tecomatlán " => "0281", "San Miguel Tenango " => "0282", "San Miguel Tequixtepec " => "0283", "San Miguel Tilquiápam " => "0284", "San Miguel Tlacamama " => "0285", "San Miguel Tlacotepec " => "0286", "San Miguel Tulancingo " => "0287", "San Miguel Yotao " => "0288", "San Nicolás " => "0289", "San Nicolás Hidalgo " => "0290", "San Pablo Coatlán " => "0291", "San Pablo Cuatro Venados " => "0292", "San Pablo Etla" => "0293", "San Pablo Huitzo" => "0294", "San Pablo Huixtepec" => "0295", "San Pablo Macuiltianguis " => "0296", "San Pablo Tijaltepec " => "0297", "San Pablo Villa de Mitla" => "0298", "San Pablo Yaganiza " => "0299", "San Pedro Amuzgos" => "0300", "San Pedro Apóstol " => "0301", "San Pedro Atoyac " => "0302", "San Pedro Cajonos " => "0303", "San Pedro Coxcaltepec Cántaros " => "0304", "San Pedro Comitancillo " => "0305", "San Pedro el Alto " => "0306", "San Pedro Huamelula" => "0307", "San Pedro Huilotepec " => "0308", "San Pedro Ixcatlán" => "0309", "San Pedro Ixtlahuaca" => "0310", "San Pedro Jaltepetongo " => "0311", "San Pedro Jicayán" => "0312", "San Pedro Jocotipac " => "0313", "San Pedro Juchatengo " => "0314", "San Pedro Mártir " => "0315", "San Pedro Mártir Quiechapa " => "0316", "San Pedro Mártir Yucuxaco " => "0317", "San Pedro Mixtepec" => "0318", "San Pedro Mixtepec " => "0319", "San Pedro Molinos " => "0320", "San Pedro Nopala " => "0321", "San Pedro Ocopetatillo " => "0322", "San Pedro Ocotepec " => "0323", "San Pedro Pochutla" => "0324", "San Pedro Quiatoni " => "0325", "San Pedro Sochiápam " => "0326", "San Pedro Tapanatepec" => "0327", "San Pedro Taviche" => "0328", "San Pedro Teozacoalco " => "0329", "San Pedro Teutila " => "0330", "San Pedro Tidaá " => "0331", "San Pedro Topiltepec " => "0332", "San Pedro Totolápam " => "0333", "Villa de Tututepec de Melchor Ocampo" => "0334", "San Pedro Yaneri " => "0335", "San Pedro Yólox " => "0336", "San Pedro y San Pablo Ayutla " => "0337", "Villa de Etla" => "0338", "San Pedro y San Pablo Teposcolula " => "0339", "San Pedro y San Pablo Tequixtepec " => "0340", "San Pedro Yucunama " => "0341", "San Raymundo Jalpan " => "0342", "San Sebastián Abasolo " => "0343", "San Sebastián Coatlán " => "0344", "San Sebastián Ixcapa " => "0345", "San Sebastián Nicananduta " => "0346", "San Sebastián Río Hondo " => "0347", "San Sebastián Tecomaxtlahuaca" => "0348", "San Sebastián Teitipac " => "0349", "San Sebastián Tutla" => "0350", "San Simón Almolongas " => "0351", "San Simón Zahuatlán " => "0352", "Santa Ana " => "0353", "Santa Ana Ateixtlahuaca " => "0354", "Santa Ana Cuauhtémoc " => "0355", "Santa Ana del Valle" => "0356", "Santa Ana Tavela " => "0357", "Santa Ana Tlapacoyan " => "0358", "Santa Ana Yareni " => "0359", "Santa Ana Zegache " => "0360", "Santa Catalina Quierí " => "0361", "Santa Catarina Cuixtla " => "0362", "Santa Catarina Ixtepeji " => "0363", "Santa Catarina Juquila" => "0364", "Santa Catarina Lachatao " => "0365", "Santa Catarina Loxicha " => "0366", "Santa Catarina Mechoacán " => "0367", "Santa Catarina Minas " => "0368", "Santa Catarina Quiané " => "0369", "Santa Catarina Tayata " => "0370", "Santa Catarina Ticuá" => "0371", "Santa Catarina Yosonotú " => "0372", "Santa Catarina Zapoquila " => "0373", "Santa Cruz Acatepec " => "0374", "Santa Cruz Amilpas" => "0375", "Santa Cruz de Bravo " => "0376", "Santa Cruz Itundujia" => "0377", "Santa Cruz Mixtepec " => "0378", "Santa Cruz Nundaco " => "0379", "Santa Cruz Papalutla " => "0380", "Santa Cruz Tacache de Mina " => "0381", "Santa Cruz Tacahua " => "0382", "Santa Cruz Tayata " => "0383", "Santa Cruz Xitla " => "0384", "Santa Cruz Xoxocotlán" => "0385", "Santa Cruz Zenzontepec " => "0386", "Santa Gertrudis " => "0387", "Santa Inés del Monte " => "0388", "Santa Inés Yatzeche " => "0389", "Santa Lucía del Camino" => "0390", "Santa Lucía Miahuatlán " => "0391", "Santa Lucía Monteverde" => "0392", "Santa Lucía Ocotlán " => "0393", "Santa María Alotepec " => "0394", "Santa María Apazco " => "0395", "Santa María la Asunción " => "0396", "Heroica Ciudad de Tlaxiaco" => "0397", "Ayoquezco de Aldama " => "0398", "Santa María Atzompa" => "0399", "Santa María Camotlán " => "0400", "Santa María Colotepec" => "0401", "Santa María Cortijo " => "0402", "Santa María Coyotepec " => "0403", "Santa María Chachoápam " => "0404", "405 Villa de Chilapa de Díaz " => "0405", "Santa María Chilchotla " => "0406", "Santa María Chimalapa " => "0407", "Santa María del Rosario " => "0408", "Santa María del Tule" => "0409", "Santa María Ecatepec " => "0410", "Santa María Guelacé " => "0411", "Santa María Guienagati " => "0412", "Santa María Huatulco" => "0413", "Santa María Huazolotitlán  " => "0414", "Santa María Ipalapa " => "0415", "Santa María Ixcatlán " => "0416", "Santa María Jacatepec" => "0417", "Santa María Jalapa del Marqués" => "0418", "Santa María Jaltianguis " => "0419", "Santa María Lachixío " => "0420", "Santa María Mixtequilla " => "0421", "Santa María Nativitas " => "0422", "Santa María Nduayaco " => "0423", "Santa María Ozolotepec " => "0424", "Santa María Pápalo " => "0425", "Santa María Peñoles " => "0426", "Santa María Petapa " => "0427", "Santa María Quiegolani " => "0428", "Santa María Sola " => "0429", "Santa María Tataltepec " => "0430", "Santa María Tecomavaca " => "0431", "Santa María Temaxcalapa " => "0432", "Santa María Temaxcaltepec " => "0433", "Santa María Teopoxco " => "0434", "Santa María Tepantlali " => "0435", "Santa María Texcatitlán " => "0436", "Santa María Tlahuitoltepec " => "0437", "Santa María Tlalixtac " => "0438", "Santa María Tonameca" => "0439", "Santa María Totolapilla " => "0440", "Santa María Xadani" => "0441", "Santa María Yalina " => "0442", "Santa María Yavesía " => "0443", "Santa María Yolotepec " => "0444", "Santa María Yosoyúa " => "0445", "Santa María Yucuhiti" => "0446", "Santa María Zacatepec" => "0447", "Santa María Zaniza " => "0448", "Santa María Zoquitlán " => "0449", "Santiago Amoltepec " => "0450", "Santiago Apoala " => "0451", "Santiago Apóstol " => "0452", "Santiago Astata " => "0453", "Santiago Atitlán " => "0454", "Santiago Ayuquililla " => "0455", "Santiago Cacaloxtepec " => "0456", "Santiago Camotlán " => "0457", "Santiago Comaltepec " => "0458", "Santiago Chazumba" => "0459", "Santiago Choápam " => "0460", "Santiago del Río " => "0461", "Santiago Huajolotitlán " => "0462", "Santiago Huauclilla" => "0463", "Santiago Ihuitlán Plumas " => "0464", "Santiago Ixcuintepec " => "0465", "Santiago Ixtayutla " => "0466", "Santiago Jamiltepec" => "0467", "Santiago Jocotepec" => "0468", "Santiago Juxtlahuaca" => "0469", "Santiago Lachiguiri" => "0470", "Santiago Lalopa " => "0471", "Santiago Laollaga " => "0472", "Santiago Laxopa " => "0473", "Santiago Llano Grande " => "0474", "Santiago Matatlán" => "0475", "Santiago Miltepec " => "0476", "Santiago Minas " => "0477", "Santiago Nacaltepec " => "0478", "Santiago Nejapilla " => "0479", "Santiago Nundiche " => "0480", "Santiago Nuyoó " => "0481", "Santiago Pinotepa Nacional" => "0482", "Santiago Suchilquitongo" => "0483", "Santiago Tamazola " => "0484", "Santiago Tapextla " => "0485", "Villa Tejúpam de la Unión " => "0486", "Santiago Tenango " => "0487", "Santiago Tepetlapa " => "0488", "Santiago Tetepec " => "0489", "Santiago Texcalcingo " => "0490", "Santiago Textitlán " => "0491", "Santiago Tilantongo " => "0492", "Santiago Tillo " => "0493", "Santiago Tlazoyaltepec " => "0494", "Santiago Xanica " => "0495", "Santiago Xiacuí " => "0496", "Santiago Yaitepec " => "0497", "Santiago Yaveo" => "0498", "Santiago Yolomécatl " => "0499", "Santiago Yosondúa" => "0500", "Santiago Yucuyachi " => "0501", "Santiago Zacatepec " => "0502", "Santiago Zoochila " => "0503", "Nuevo Zoquiápam " => "0504", "Santo Domingo Ingenio" => "0505", "Santo Domingo Albarradas " => "0506", "Santo Domingo Armenta " => "0507", "Santo Domingo Chihuitán " => "0508", "Santo Domingo de Morelos " => "0509", "Santo Domingo Ixcatlán " => "0510", "Santo Domingo Nuxaá " => "0511", "Santo Domingo Ozolotepec " => "0512", "Santo Domingo Petapa" => "0513", "Santo Domingo Roayaga " => "0514", "Santo Domingo Tehuantepec" => "0515", "Santo Domingo Teojomulco " => "0516", "Santo Domingo Tepuxtepec " => "0517", "Santo Domingo Tlatayápam " => "0518", "Santo Domingo Tomaltepec " => "0519", "Santo Domingo Tonalá" => "0520", "Santo Domingo Tonaltepec " => "0521", "Santo Domingo Xagacía " => "0522", "Santo Domingo Yanhuitlán " => "0523", "Santo Domingo Yodohino " => "0524", "Santo Domingo Zanatepec" => "0525", "Santos Reyes Nopala" => "0526", "Santos Reyes Pápalo " => "0527", "Santos Reyes Tepejillo " => "0528", "Santos Reyes Yucuná " => "0529", "Santo Tomás Jalieza" => "0530", "Santo Tomás Mazaltepec " => "0531", "Santo Tomás Ocotepec " => "0532", "Santo Tomás Tamazulapan" => "0533", "San Vicente Coatlán " => "0534", "San Vicente Lachixío " => "0535", "San Vicente Nuñú " => "0536", "Silacayoápam" => "0537", "Sitio de Xitlapehua " => "0538", "Soledad Etla " => "0539", "Villa de Tamazulápam del Progreso" => "0540", "Tanetze de Zaragoza " => "0541", "Taniche " => "0542", "Tataltepec de Valdés " => "0543", "Teococuilco de Marcos Pérez " => "0544", "Teotitlán de Flores Magón" => "0545", "Teotitlán del Valle" => "0546", "Teotongo" => "0547", "Tepelmeme Villa de Morelos" => "0548", "Heroica Villa Tezoatlán de Segura y Luna, Cuna de la Independencia de Oaxaca" => "0549", "San Jerónimo Tlacochahuaya" => "0550", "Tlacolula de Matamoros" => "0551", "Tlacotepec Plumas " => "0552", "Tlalixtac de Cabrera" => "0553", "Totontepec Villa de Morelos " => "0554", "Trinidad Zaachila " => "0555", "La Trinidad Vista Hermosa " => "0556", "Unión Hidalgo" => "0557", "Valerio Trujano " => "0558", "San Juan Bautista Valle Nacional" => "0559", "Villa Díaz Ordaz" => "0560", "Yaxe " => "0561", "Magdalena Yodocono de Porfirio Díaz " => "0562", "Yogana " => "0563", "Yutanduchi de Guerrero " => "0564", "Villa de Zaachila" => "0565", "San Mateo Yucutindoo " => "0566", "Zapotitlán Lagunas " => "0567", "Zapotitlán Palmas " => "0568", "Santa Inés de Zaragoza " => "0569", "Zimatlán de Álvarez" => "0570");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Puebla", "Not founded"))] = Dict("Total estatal" => "", "Acajete" => "0001", "Acateno" => "0002", "Acatlán" => "0003", "Acatzingo" => "0004", "Acteopan " => "0005", "Ahuacatlán" => "0006", "Ahuatlán " => "0007", "Ahuazotepec" => "0008", "Ahuehuetitla " => "0009", "Ajalpan" => "0010", "Albino Zertuche " => "0011", "Aljojuca" => "0012", "Altepexi" => "0013", "Amixtlán " => "0014", "Amozoc" => "0015", "Aquixtla" => "0016", "Atempan" => "0017", "Atexcal " => "0018", "Atlequizayan " => "0080", "Atlixco" => "0019", "Atoyatempan" => "0020", "Atzala " => "0021", "Atzitzihuacán" => "0022", "Atzitzintla" => "0023", "Axutla " => "0024", "Ayotoxco de Guerrero" => "0025", "Calpan" => "0026", "Caltepec " => "0027", "Camocuautla " => "0028", "Cañada Morelos" => "0099", "Caxhuacan " => "0029", "Chalchicomula de Sesma" => "0045", "Chapulco" => "0046", "Chiautla" => "0047", "Chiautzingo" => "0048", "Chichiquila" => "0050", "Chiconcuautla" => "0049", "Chietla" => "0051", "Chigmecatitlán " => "0052", "Chignahuapan" => "0053", "Chignautla" => "0054", "Chila " => "0055", "Chila de la Sal " => "0056", "Chilchotla" => "0058", "Chinantla " => "0059", "Coatepec " => "0030", "Coatzingo " => "0031", "Cohetzala " => "0032", "Cohuecan " => "0033", "Coronango" => "0034", "Coxcatlán" => "0035", "Coyomeapan " => "0036", "Coyotepec " => "0037", "Cuapiaxtla de Madero" => "0038", "Cuautempan" => "0039", "Cuautinchán" => "0040", "Cuautlancingo" => "0041", "Cuayuca de Andrade " => "0042", "Cuetzalan del Progreso" => "0043", "Cuyoaco" => "0044", "Domingo Arenas" => "0060", "Eloxochitlán " => "0061", "Epatlán " => "0062", "Esperanza" => "0063", "Francisco Z. Mena" => "0064", "General Felipe Ángeles" => "0065", "Guadalupe" => "0066", "Guadalupe Victoria" => "0067", "Hermenegildo Galeana" => "0068", "Honey" => "0057", "Huaquechula" => "0069", "Huatlatlauca" => "0070", "Huauchinango" => "0071", "Huehuetla" => "0072", "Huehuetlán el Chico" => "0073", "Huehuetlán el Grande" => "0150", "Huejotzingo" => "0074", "Hueyapan" => "0075", "Hueytamalco" => "0076", "Hueytlalpan " => "0077", "Huitzilan de Serdán" => "0078", "Huitziltepec " => "0079", "Ixcamilpa de Guerrero " => "0081", "Ixcaquixtla" => "0082", "Ixtacamaxtitlán" => "0083", "Ixtepec" => "0084", "Izúcar de Matamoros" => "0085", "Jalpan" => "0086", "Jolalpan" => "0087", "Jonotla " => "0088", "Jopala" => "0089", "Juan C. Bonilla" => "0090", "Juan Galindo" => "0091", "Juan N. Méndez " => "0092", "La Magdalena Tlatlauquitepec " => "0095", "Lafragua" => "0093", "Libres" => "0094", "Los Reyes de Juárez" => "0118", "Mazapiltepec de Juárez " => "0096", "Mixtla " => "0097", "Molcaxac" => "0098", "Naupan" => "0100", "Nauzontla " => "0101", "Nealtican" => "0102", "Nicolás Bravo" => "0103", "Nopalucan" => "0104", "Ocotepec " => "0105", "Ocoyucan" => "0106", "Olintla" => "0107", "Oriental" => "0108", "Pahuatlán" => "0109", "Palmar de Bravo" => "0110", "Pantepec" => "0111", "Petlalcingo" => "0112", "Piaxtla " => "0113", "Puebla" => "0114", "Quecholac" => "0115", "Quimixtlán" => "0116", "Rafael Lara Grajales" => "0117", "San Andrés Cholula" => "0119", "San Antonio Cañada " => "0120", "San Diego la Mesa Tochimiltzingo " => "0121", "San Felipe Teotlalcingo" => "0122", "San Felipe Tepatlán " => "0123", "San Gabriel Chilac" => "0124", "San Gregorio Atzompa" => "0125", "San Jerónimo Tecuanipan " => "0126", "San Jerónimo Xayacatlán " => "0127", "San José Chiapa" => "0128", "San José Miahuatlán" => "0129", "San Juan Atenco " => "0130", "San Juan Atzompa " => "0131", "San Martín Texmelucan" => "0132", "San Martín Totoltepec " => "0133", "San Matías Tlalancaleca" => "0134", "San Miguel Ixitlán " => "0135", "San Miguel Xoxtla" => "0136", "San Nicolás Buenos Aires" => "0137", "San Nicolás de los Ranchos " => "0138", "San Pablo Anicano " => "0139", "San Pedro Cholula" => "0140", "San Pedro Yeloixtlahuaca " => "0141", "San Salvador el Seco" => "0142", "San Salvador el Verde" => "0143", "San Salvador Huixcolotla" => "0144", "San Sebastián Tlacotepec" => "0145", "Santa Catarina Tlaltempan " => "0146", "Santa Inés Ahuatempan" => "0147", "Santa Isabel Cholula" => "0148", "Santiago Miahuatlán" => "0149", "Santo Tomás Hueyotlipan" => "0151", "Soltepec" => "0152", "Tecali de Herrera" => "0153", "Tecamachalco" => "0154", "Tecomatlán" => "0155", "Tehuacán" => "0156", "Tehuitzingo" => "0157", "Tenampulco" => "0158", "Teopantlán " => "0159", "Teotlalco " => "0160", "Tepanco de López" => "0161", "Tepango de Rodríguez " => "0162", "Tepatlaxco de Hidalgo" => "0163", "Tepeaca" => "0164", "Tepemaxalco " => "0165", "Tepeojuma" => "0166", "Tepetzintla" => "0167", "Tepexco" => "0168", "Tepexi de Rodríguez" => "0169", "Tepeyahualco" => "0170", "Tepeyahualco de Cuauhtémoc " => "0171", "Tetela de Ocampo" => "0172", "Teteles de Avila Castillo" => "0173", "Teziutlán" => "0174", "Tianguismanalco" => "0175", "Tilapa" => "0176", "Tlachichuca" => "0179", "Tlacotepec de Benito Juárez" => "0177", "Tlacuilotepec" => "0178", "Tlahuapan" => "0180", "Tlaltenango" => "0181", "Tlanepantla " => "0182", "Tlaola" => "0183", "Tlapacoya" => "0184", "Tlapanalá" => "0185", "Tlatlauquitepec" => "0186", "Tlaxco" => "0187", "Tochimilco" => "0188", "Tochtepec" => "0189", "Totoltepec de Guerrero " => "0190", "Tulcingo" => "0191", "Tuzamapan de Galeana" => "0192", "Tzicatlacoyan" => "0193", "Venustiano Carranza" => "0194", "Vicente Guerrero " => "0195", "Xayacatlán de Bravo " => "0196", "Xicotepec" => "0197", "Xicotlán " => "0198", "Xiutetelco" => "0199", "Xochiapulco " => "0200", "Xochiltepec " => "0201", "Xochitlán de Vicente Suárez" => "0202", "Xochitlán Todos Santos" => "0203", "Yaonáhuac" => "0204", "Yehualtepec" => "0205", "Zacapala " => "0206", "Zacapoaxtla" => "0207", "Zacatlán" => "0208", "Zapotitlán" => "0209", "Zapotitlán de Méndez " => "0210", "Zaragoza" => "0211", "Zautla" => "0212", "Zihuateutla" => "0213", "Zinacatepec" => "0214", "Zongozotla " => "0215", "Zoquiapan " => "0216", "Zoquitlán " => "0217");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Querétaro", "Not founded"))] = Dict("Total estatal" => "", "Amealco de Bonfil" => "0001", "Pinal de Amoles" => "0002", "Arroyo Seco" => "0003", "Cadereyta de Montes" => "0004", "Colón" => "0005", "Corregidora" => "0006", "Ezequiel Montes" => "0007", "Huimilpan" => "0008", "Jalpan de Serra" => "0009", "Landa de Matamoros" => "0010", "El Marqués" => "0011", "Pedro Escobedo" => "0012", "Peñamiller" => "0013", "Querétaro" => "0014", "San Joaquín" => "0015", "San Juan del Río" => "0016", "Tequisquiapan" => "0017", "Tolimán" => "0018");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Quintana Roo", "Not founded"))] = Dict("Total estatal" => "", "Cozumel" => "0001", "Felipe Carrillo Puerto" => "0002", "Isla Mujeres" => "0003", "Othón P. Blanco" => "0004", "Benito Juárez" => "0005", "José María Morelos" => "0006", "Lázaro Cárdenas" => "0007", "Solidaridad" => "0008", "Tulum" => "0009", "Bacalar" => "0010", "Puerto Morelos" => "0011");

diccionario_municipios[parse(Int64, get(diccionario_estados, "San Luis Potosí", "Not founded"))] = Dict("Total estatal" => "", "Ahualulco" => "0001", "Alaquines" => "0002", "Aquismón" => "0003", "Armadillo de los Infante" => "0004", "Axtla de Terrazas" => "0053", "Cárdenas" => "0005", "Catorce" => "0006", "Cedral" => "0007", "Cerritos" => "0008", "Cerro de San Pedro" => "0009", "Charcas" => "0015", "Ciudad del Maíz" => "0010", "Ciudad Fernández" => "0011", "Ciudad Valles" => "0013", "Coxcatlán" => "0014", "Ebano" => "0016", "El Naranjo" => "0058", "Guadalcázar" => "0017", "Huehuetlán" => "0018", "Lagunillas" => "0019", "Matehuala" => "0020", "Matlapa" => "0057", "Mexquitic de Carmona" => "0021", "Moctezuma" => "0022", "Rayón" => "0023", "Rioverde" => "0024", "Salinas" => "0025", "San Antonio" => "0026", "San Ciro de Acosta" => "0027", "San Luis Potosí" => "0028", "San Martín Chalchicuautla" => "0029", "San Nicolás Tolentino" => "0030", "San Vicente Tancuayalab" => "0034", "Santa Catarina" => "0031", "Santa María del Río" => "0032", "Santo Domingo" => "0033", "Soledad de Graciano Sánchez" => "0035", "Tamasopo" => "0036", "Tamazunchale" => "0037", "Tampacán" => "0038", "Tampamolón Corona" => "0039", "Tamuín" => "0040", "Tancanhuitz" => "0012", "Tanlajás" => "0041", "Tanquián de Escobedo" => "0042", "Tierra Nueva" => "0043", "Vanegas" => "0044", "Venado" => "0045", "Villa de Arista" => "0056", "Villa de Arriaga" => "0046", "Villa de Guadalupe" => "0047", "Villa de la Paz" => "0048", "Villa de Ramos" => "0049", "Villa de Reyes" => "0050", "Villa Hidalgo" => "0051", "Villa Juárez" => "0052", "Xilitla" => "0054", "Zaragoza" => "0055");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Sinaloa", "Not founded"))] = Dict("Total estatal" => "", "Ahome" => "0001", "Angostura" => "0002", "Badiraguato" => "0003", "Concordia" => "0004", "Cosalá" => "0005", "Culiacán" => "0006", "Choix" => "0007", "Elota" => "0008", "Escuinapa" => "0009", "El Fuerte" => "0010", "Guasave" => "0011", "Mazatlán" => "0012", "Mocorito" => "0013", "Rosario" => "0014", "Salvador Alvarado" => "0015", "San Ignacio" => "0016", "Sinaloa" => "0017", "Navolato" => "0018");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Sonora", "Not founded"))] = Dict("Total estatal" => "", "Aconchi " => "0001", "Agua Prieta" => "0002", "Alamos" => "0003", "Altar" => "0004", "Arivechi" => "0005", "Arizpe" => "0006", "Atil" => "0007", "Bacadéhuachi" => "0008", "Bacanora" => "0009", "Bacerac" => "0010", "Bacoachi" => "0011", "Bácum" => "0012", "Banámichi" => "0013", "Baviácora" => "0014", "Bavispe" => "0015", "Benito Juárez" => "0071", "Benjamín Hill" => "0016", "Caborca" => "0017", "Cajeme" => "0018", "Cananea" => "0019", "Carbó" => "0020", "Cucurpe" => "0022", "Cumpas" => "0023", "Divisaderos" => "0024", "Empalme" => "0025", "Etchojoa" => "0026", "Fronteras" => "0027", "General Plutarco Elías Calles" => "0070", "Granados" => "0028", "Guaymas" => "0029", "Hermosillo" => "0030", "Huachinera " => "0031", "Huásabas" => "0032", "Huatabampo" => "0033", "Huépac" => "0034", "Imuris" => "0035", "La Colorada" => "0021", "Magdalena" => "0036", "Mazatán" => "0037", "Moctezuma" => "0038", "Naco" => "0039", "Nácori Chico" => "0040", "Nacozari de García" => "0041", "Navojoa" => "0042", "Nogales" => "0043", "Onavas" => "0044", "Opodepe" => "0045", "Oquitoa" => "0046", "Pitiquito" => "0047", "Puerto Peñasco" => "0048", "Quiriego" => "0049", "Rayón" => "0050", "Rosario" => "0051", "Sahuaripa" => "0052", "San Felipe de Jesús" => "0053", "San Ignacio Río Muerto" => "0072", "San Javier" => "0054", "San Luis Río Colorado" => "0055", "San Miguel de Horcasitas" => "0056", "San Pedro de la Cueva" => "0057", "Santa Ana" => "0058", "Santa Cruz" => "0059", "Sáric" => "0060", "Soyopa" => "0061", "Suaqui Grande" => "0062", "Tepache" => "0063", "Trincheras" => "0064", "Tubutama" => "0065", "Ures" => "0066", "Villa Hidalgo" => "0067", "Villa Pesqueira " => "0068", "Yécora" => "0069");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Tabasco", "Not founded"))] = Dict("Total estatal" => "", "Balancán" => "0001", "Cárdenas" => "0002", "Centla" => "0003", "Centro" => "0004", "Comalcalco" => "0005", "Cunduacán" => "0006", "Emiliano Zapata" => "0007", "Huimanguillo" => "0008", "Jalapa" => "0009", "Jalpa de Méndez" => "0010", "Jonuta" => "0011", "Macuspana" => "0012", "Nacajuca" => "0013", "Paraíso" => "0014", "Tacotalpa" => "0015", "Teapa" => "0016", "Tenosique" => "0017");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Tamaulipas", "Not founded"))] = Dict("Total estatal" => "", "Abasolo" => "0001", "Aldama" => "0002", "Altamira" => "0003", "Antiguo Morelos" => "0004", "Burgos" => "0005", "Bustamante" => "0006", "Camargo" => "0007", "Casas" => "0008", "Ciudad Madero" => "0009", "Cruillas" => "0010", "El Mante" => "0021", "Gómez Farías" => "0011", "González" => "0012", "Güémez" => "0013", "Guerrero" => "0014", "Gustavo Díaz Ordaz" => "0015", "Hidalgo" => "0016", "Jaumave" => "0017", "Jiménez" => "0018", "Llera" => "0019", "Mainero" => "0020", "Matamoros" => "0022", "Méndez" => "0023", "Mier" => "0024", "Miguel Alemán" => "0025", "Miquihuana" => "0026", "Nuevo Laredo" => "0027", "Nuevo Morelos" => "0028", "Ocampo" => "0029", "Padilla" => "0030", "Palmillas" => "0031", "Reynosa" => "0032", "Río Bravo" => "0033", "San Carlos" => "0034", "San Fernando" => "0035", "San Nicolás" => "0036", "Soto la Marina" => "0037", "Tampico" => "0038", "Tula" => "0039", "Valle Hermoso" => "0040", "Victoria" => "0041", "Villagrán" => "0042", "Xicoténcatl" => "0043");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Tlaxcala", "Not founded"))] = Dict("Total estatal" => "", "Amaxac de Guerrero" => "0001", "Apetatitlán de Antonio Carvajal" => "0002", "Atlangatepec" => "0003", "Atltzayanca" => "0004", "Apizaco" => "0005", "Calpulalpan" => "0006", "El Carmen Tequexquitla" => "0007", "Cuapiaxtla" => "0008", "Cuaxomulco" => "0009", "Chiautempan" => "0010", "Muñoz de Domingo Arenas" => "0011", "Españita" => "0012", "Huamantla" => "0013", "Hueyotlipan" => "0014", "Ixtacuixtla de Mariano Matamoros" => "0015", "Ixtenco" => "0016", "Mazatecochco de José María Morelos" => "0017", "Contla de Juan Cuamatzi" => "0018", "Tepetitla de Lardizábal" => "0019", "Sanctórum de Lázaro Cárdenas" => "0020", "Nanacamilpa de Mariano Arista" => "0021", "Acuamanala de Miguel Hidalgo" => "0022", "Natívitas" => "0023", "Panotla" => "0024", "San Pablo del Monte" => "0025", "Santa Cruz Tlaxcala" => "0026", "Tenancingo" => "0027", "Teolocholco" => "0028", "Tepeyanco" => "0029", "Terrenate" => "0030", "Tetla de la Solidaridad" => "0031", "Tetlatlahuca" => "0032", "Tlaxcala" => "0033", "Tlaxco" => "0034", "Tocatlán" => "0035", "Totolac" => "0036", "Ziltlaltépec de Trinidad Sánchez Santos" => "0037", "Tzompantepec" => "0038", "Xaloztoc" => "0039", "Xaltocan" => "0040", "Papalotla de Xicohténcatl" => "0041", "Xicohtzinco" => "0042", "Yauhquemehcan" => "0043", "Zacatelco" => "0044", "Benito Juárez" => "0045", "Emiliano Zapata" => "0046", "Lázaro Cárdenas" => "0047", "La Magdalena Tlaltelulco" => "0048", "San Damián Texóloc" => "0049", "San Francisco Tetlanohcan" => "0050", "San Jerónimo Zacualpan " => "0051", "San José Teacalco " => "0052", "San Juan Huactzinco" => "0053", "San Lorenzo Axocomanitla" => "0054", "San Lucas Tecopilco" => "0055", "Santa Ana Nopalucan" => "0056", "Santa Apolonia Teacalco" => "0057", "Santa Catarina Ayometla" => "0058", "Santa Cruz Quilehtla" => "0059", "Santa Isabel Xiloxoxtla" => "0060");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Veracruz de Ignacio de la Llave", "Not founded"))] = Dict("Total estatal" => "", "Chiconquiaco" => "0057", "Chicontepec" => "0058", "Chinameca" => "0059", "Chinampa de Gorostiza" => "0060", "Las Choapas" => "0061", "Chocamán" => "0062", "Chontla" => "0063", "Chumatlán " => "0064", "Emiliano Zapata" => "0065", "Espinal" => "0066", "Filomeno Mata" => "0067", "Fortín" => "0068", "Gutiérrez Zamora" => "0069", "Hidalgotitlán" => "0070", "Huatusco" => "0071", "Huayacocotla" => "0072", "Hueyapan de Ocampo" => "0073", "Huiloapan de Cuauhtémoc" => "0074", "Ignacio de la Llave" => "0075", "Ilamatlán " => "0076", "Isla" => "0077", "Ixcatepec" => "0078", "Ixhuacán de los Reyes" => "0079", "Ixhuatlán del Café" => "0080", "Ixhuatlancillo" => "0081", "Ixhuatlán del Sureste" => "0082", "Ixhuatlán de Madero" => "0083", "Ixmatlahuacan" => "0084", "Ixtaczoquitlán" => "0085", "Jalacingo" => "0086", "Xalapa" => "0087", "Jalcomulco" => "0088", "Jáltipan" => "0089", "Jamapa" => "0090", "Jesús Carranza" => "0091", "Xico" => "0092", "Jilotepec" => "0093", "Juan Rodríguez Clara" => "0094", "Juchique de Ferrer" => "0095", "Landero y Coss " => "0096", "Lerdo de Tejada" => "0097", "Magdalena " => "0098", "Maltrata" => "0099", "Manlio Fabio Altamirano" => "0100", "Mariano Escobedo" => "0101", "Martínez de la Torre" => "0102", "Mecatlán " => "0103", "Mecayapan " => "0104", "Medellín de Bravo" => "0105", "Miahuatlán " => "0106", "Las Minas " => "0107", "Minatitlán" => "0108", "Misantla" => "0109", "Mixtla de Altamirano " => "0110", "Moloacán" => "0111", "Naolinco" => "0112", "Naranjal " => "0113", "Nautla" => "0114", "Nogales" => "0115", "Oluta" => "0116", "Omealca" => "0117", "Orizaba" => "0118", "Otatitlán" => "0119", "Oteapan" => "0120", "Ozuluama de Mascareñas" => "0121", "Pajapan" => "0122", "Pánuco" => "0123", "Papantla" => "0124", "Paso del Macho" => "0125", "Paso de Ovejas" => "0126", "La Perla" => "0127", "Perote" => "0128", "Platón Sánchez" => "0129", "Playa Vicente" => "0130", "Poza Rica de Hidalgo" => "0131", "Las Vigas de Ramírez" => "0132", "Pueblo Viejo" => "0133", "Puente Nacional" => "0134", "Rafael Delgado" => "0135", "Rafael Lucio" => "0136", "Los Reyes " => "0137", "Río Blanco" => "0138", "Saltabarranca" => "0139", "San Andrés Tenejapan " => "0140", "San Andrés Tuxtla" => "0141", "San Juan Evangelista" => "0142", "Santiago Tuxtla" => "0143", "Sayula de Alemán" => "0144", "Soconusco" => "0145", "Sochiapa " => "0146", "Soledad Atzompa " => "0147", "Soledad de Doblado" => "0148", "Soteapan" => "0149", "Tamalín" => "0150", "Tamiahua" => "0151", "Tampico Alto" => "0152", "Tancoco" => "0153", "Tantima" => "0154", "Tantoyuca" => "0155", "Tatatila " => "0156", "Castillo de Teayo" => "0157", "Tecolutla" => "0158", "Tehuipango " => "0159", "Álamo Temapache" => "0160", "Tempoal" => "0161", "Tenampa" => "0162", "Tenochtitlán " => "0163", "Teocelo" => "0164", "Tepatlaxco" => "0165", "Tepetlán" => "0166", "Tepetzintla" => "0167", "Tequila" => "0168", "José Azueta" => "0169", "Texcatepec " => "0170", "Texhuacán " => "0171", "Texistepec" => "0172", "Tezonapa" => "0173", "Tierra Blanca" => "0174", "Tihuatlán" => "0175", "Tlacojalpan" => "0176", "Tlacolulan" => "0177", "Tlacotalpan" => "0178", "Tlacotepec de Mejía " => "0179", "Tlachichilco" => "0180", "Tlalixcoyan" => "0181", "Tlalnelhuayocan" => "0182", "Tlapacoyan" => "0183", "Tlaquilpa" => "0184", "Tlilapan " => "0185", "Tomatlán" => "0186", "Tonayán " => "0187", "Totutla" => "0188", "Tuxpan" => "0189", "Tuxtilla " => "0190", "Ursulo Galván" => "0191", "Vega de Alatorre" => "0192", "Veracruz" => "0193", "Villa Aldama" => "0194", "Xoxocotla " => "0195", "Yanga" => "0196", "Yecuatla" => "0197", "Zacualpan" => "0198", "Zaragoza" => "0199", "Zentla" => "0200", "Zongolica" => "0201", "Zontecomatlán de López y Fuentes" => "0202", "Zozocolco de Hidalgo" => "0203", "Agua Dulce" => "0204", "El Higo" => "0205", "Nanchital de Lázaro Cárdenas del Río" => "0206", "Tres Valles" => "0207", "Carlos A. Carrillo" => "0208", "Tatahuicapan de Juárez" => "0209", "Uxpanapa" => "0210", "San Rafael" => "0211", "Santiago Sochiapan" => "0212");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Yucatán", "Not founded"))] = Dict("Total estatal" => "", "Abalá" => "0001", "Acanceh" => "0002", "Akil" => "0003", "Baca" => "0004", "Bokobá " => "0005", "Buctzotz" => "0006", "Cacalchén" => "0007", "Calotmul " => "0008", "Cansahcab" => "0009", "Cantamayec" => "0010", "Celestún" => "0011", "Cenotillo" => "0012", "Conkal" => "0013", "Cuncunul" => "0014", "Cuzamá" => "0015", "Chacsinkín" => "0016", "Chankom" => "0017", "Chapab" => "0018", "Chemax" => "0019", "Chicxulub Pueblo" => "0020", "Chichimilá" => "0021", "Chikindzonot" => "0022", "Chocholá" => "0023", "Chumayel" => "0024", "Dzán" => "0025", "Dzemul" => "0026", "Dzidzantún" => "0027", "Dzilam de Bravo" => "0028", "Dzilam González" => "0029", "Dzitás" => "0030", "Dzoncauich" => "0031", "Espita" => "0032", "Halachó" => "0033", "Hocabá" => "0034", "Hoctún" => "0035", "Homún" => "0036", "Huhí" => "0037", "Hunucmá" => "0038", "Ixil" => "0039", "Izamal" => "0040", "Kanasín" => "0041", "Kantunil" => "0042", "Kaua" => "0043", "Kinchil" => "0044", "Kopomá" => "0045", "Mama" => "0046", "Maní" => "0047", "Maxcanú" => "0048", "Mayapán" => "0049", "Mérida" => "0050", "Mocochá" => "0051", "Motul" => "0052", "Muna" => "0053", "Muxupip" => "0054", "Opichén" => "0055", "Oxkutzcab" => "0056", "Panabá" => "0057", "Peto" => "0058", "Progreso" => "0059", "Quintana Roo" => "0060", "Río Lagartos" => "0061", "Sacalum" => "0062", "Samahil" => "0063", "Sanahcat" => "0064", "San Felipe" => "0065", "Santa Elena" => "0066", "Seyé" => "0067", "Sinanché" => "0068", "Sotuta" => "0069", "Sucilá" => "0070", "Sudzal" => "0071", "Suma" => "0072", "Tahdziú" => "0073", "Tahmek" => "0074", "Teabo" => "0075", "Tecoh" => "0076", "Tekal de Venegas" => "0077", "Tekantó" => "0078", "Tekax" => "0079", "Tekit" => "0080", "Tekom" => "0081", "Telchac Pueblo" => "0082", "Telchac Puerto" => "0083", "Temax" => "0084", "Temozón" => "0085", "Tepakán" => "0086", "Tetiz" => "0087", "Teya" => "0088", "Ticul" => "0089", "Timucuy" => "0090", "Tinum" => "0091", "Tixcacalcupul" => "0092", "Tixkokob" => "0093", "Tixmehuac" => "0094", "Tixpéhual" => "0095", "Tizimín" => "0096", "Tunkás" => "0097", "Tzucacab" => "0098", "Uayma" => "0099", "Ucú" => "0100", "Umán" => "0101", "Valladolid" => "0102", "Xocchel" => "0103", "Yaxcabá" => "0104", "Yaxkukul" => "0105", "Yobaín" => "0106");

diccionario_municipios[parse(Int64, get(diccionario_estados, "Zacatecas", "Not founded"))] = Dict("Total estatal" => "", "Apozol" => "0001", "Apulco" => "0002", "Atolinga" => "0003", "Benito Juárez" => "0004", "Calera" => "0005", "Cañitas de Felipe Pescador" => "0006", "Concepción del Oro" => "0007", "Cuauhtémoc" => "0008", "Chalchihuites" => "0009", "Fresnillo" => "0010", "Trinidad García de la Cadena" => "0011", "Genaro Codina" => "0012", "General Enrique Estrada" => "0013", "General Francisco R. Murguía" => "0014", "El Plateado de Joaquín Amaro" => "0015", "General Pánfilo Natera" => "0016", "Guadalupe" => "0017", "Huanusco" => "0018", "Jalpa" => "0019", "Jerez" => "0020", "Jiménez del Teul" => "0021", "Juan Aldama" => "0022", "Juchipila" => "0023", "Loreto" => "0024", "Luis Moya" => "0025", "Mazapil" => "0026", "Melchor Ocampo" => "0027", "Mezquital del Oro" => "0028", "Miguel Auza" => "0029", "Momax " => "0030", "Monte Escobedo" => "0031", "Morelos" => "0032", "Moyahua de Estrada" => "0033", "Nochistlán de Mejía" => "0034", "Noria de Ángeles" => "0035", "Ojocaliente" => "0036", "Pánuco" => "0037", "Pinos" => "0038", "Río Grande" => "0039", "Sain Alto" => "0040", "El Salvador" => "0041", "Sombrerete" => "0042", "Susticacán " => "0043", "Tabasco" => "0044", "Tepechitlán" => "0045", "Tepetongo" => "0046", "Teúl de González Ortega" => "0047", "Tlaltenango de Sánchez Román" => "0048", "Valparaíso" => "0049", "Vetagrande" => "0050", "Villa de Cos" => "0051", "Villa García" => "0052", "Villa González Ortega" => "0053", "Villa Hidalgo" => "0054", "Villanueva" => "0055", "Zacatecas" => "0056", "Trancoso" => "0057", "Santa María de la Paz" => "0058");


text:
using BinaryBuilder
using GitHub, Test, VT100, Sockets
import Pkg

if Sys.islinux()

# Create fake terminal to communicate with BinaryBuilder over
pty = VT100.create_pty(false)
ins, outs = Base.TTY(pty.slave; readable=true), Base.TTY(pty.slave; readable=false)

# Helper function to create a state, assign input/output streams, assign platforms, etc...
function BinaryBuilder.WizardState(ins::Base.TTY, outs::Base.TTY)
    state = BinaryBuilder.WizardState()
    state.ins = ins
    state.outs = outs
    state.platforms = supported_platforms()
    return state
end

# Test the download stage
## Tarballs
using HTTP

r = HTTP.Router()
build_tests_dir = joinpath(dirname(dirname(pathof(BinaryBuilder))), "test", "build_tests")
tar_libfoo() = read(`tar czf - -C $(build_tests_dir) libfoo`)
function serve_tgz(req)
    HTTP.Response(200, tar_libfoo())
end
HTTP.register!(r, "/*/source.tar.gz", HTTP.HandlerFunction(serve_tgz))
server = HTTP.Server(r)
@async HTTP.serve(server, ip"127.0.0.1", 14444; verbose=false)

# Test one tar.gz download
let state = BinaryBuilder.WizardState(ins, outs)
    state.step = :step2
    t = @async do_try(()->BinaryBuilder.step2(state))
    # URL
    write(pty.master, "http://127.0.0.1:14444/a/source.tar.gz\n")
    # Would you like to download additional sources?
    write(pty.master, "N\n")
    # Do you require any (binary) dependencies ?
    write(pty.master, "N\n")
    # Wait for that step to complete
    wait(t)
end

# Test two tar.gz download
let state = BinaryBuilder.WizardState(ins, outs)
    state.step = :step2
    t = @async do_try(()->BinaryBuilder.step2(state))
    # URL
    write(pty.master, "http://127.0.0.1:14444/a/source.tar.gz\n")
    # Would you like to download additional sources?
    write(pty.master, "y\n")
    write(pty.master, "http://127.0.0.1:14444/b/source.tar.gz\n")
    # Would you like to download additional sources?
    write(pty.master, "N\n")
    # Do you require any (binary) dependencies ?
    write(pty.master, "N\n")
    # Wait for that step to complete
    wait(t)
end

# Package up libfoo and dump a tarball in /tmp
tempspace = tempname()
mkdir(tempspace)
tar_hash = nothing
open(joinpath(tempspace, "source.tar.gz"), "w") do f
    data = tar_libfoo()
    global tar_hash = BinaryProvider.sha256(data)
    write(f, data)
end

# Test step3 success path
let state = BinaryBuilder.WizardState(ins, outs)
    state.step = :step3
    state.source_urls = ["http://127.0.0.1:14444/a/source.tar.gz\n"]
    state.source_files = [joinpath(tempspace, "source.tar.gz")]
    state.source_hashes = [bytes2hex(tar_hash)]
    state.platforms = [Linux(:x86_64)]
    t = @async do_try(()->BinaryBuilder.step34(state))
    write(pty.master, "cd libfoo/\n")
    write(pty.master, "make install\n")
    write(pty.master, "exit\n")
    readuntil(pty.master, "Would you like to edit this script now?")
    write(pty.master, "N\n")
    # Step 4
    write(pty.master, "ad")
    write(pty.master, "libfoo\nfooifier\n")
    wait(t)
end

# Test download with a broken symlink that used to kill the wizard
# https://github.com/JuliaPackaging/BinaryBuilder.jl/issues/183
let state = BinaryBuilder.WizardState(ins, outs)
    # download tarball with known broken symlink
    bsym_url = "https://github.com/staticfloat/small_bin/raw/d846f4a966883e7cc032a84acf4fa36695d05482/broken_symlink/broken_symlink.tar.gz"
    bsym_hash = "470d47f1e6719df286dade223605e0c7e78e2740e9f0ecbfa608997d52a00445"
    bsym_path = joinpath(tempspace, "broken_symlink.tar.gz")
    download_verify(bsym_url, bsym_hash, bsym_path)

    state.step = :step3
    state.source_urls = [bsym_url]
    state.source_files = [bsym_path]
    state.source_hashes = [bsym_hash]
    t = @async do_try(()->BinaryBuilder.step34(state))

    # If we get this far we've already won, follow through for good measure
    write(pty.master, "mkdir -p \$prefix/bin\n")
    write(pty.master, "cp /bin/bash \$prefix/bin/\n")
    write(pty.master, "exit\n")
    # We do not want to edit the script now
    readuntil(pty.master, "Would you like to edit this script now?")
    write(pty.master, "N\n")
    readuntil(pty.master, "unique variable name for each build artifact:")
    # Name the 'binary artifact' `bash`:
    write(pty.master, "bash\n")

    # Wait for the step to complete
    wait(t)
end

# Clear anything waiting to be read on `pty.master`
readavailable(pty.master)

# These technically should wait until the terminal has been put into/come out
# of raw mode.  We could probably detect that, but good enough for now.
wait_for_menu(pty) = sleep(1)
wait_for_non_menu(pty) = sleep(1)

# Step 3 failure path (no binary in destdir -> return to build)
let state = BinaryBuilder.WizardState(ins, outs)
    state.step = :step3
    state.source_urls = ["http://127.0.0.1:14444/a/source.tar.gz\n"]
    state.source_files = [joinpath(tempspace, "source.tar.gz")]
    state.source_hashes = [bytes2hex(tar_hash)]
    state.platforms = [Linux(:x86_64)]
    t = @async do_try(()->BinaryBuilder.step34(state))
    sleep(1)
    write(pty.master, "cd libfoo/\n")
    write(pty.master, "make install\n")
    write(pty.master, "rm -rf \$prefix/*\n")
    write(pty.master, "exit\n")
    readuntil(pty.master, "Would you like to edit this script now?")
    write(pty.master, "N\n")
    wait_for_menu(pty)
    write(pty.master, "\r")
    wait_for_non_menu(pty)
    write(pty.master, "cd libfoo/\n")
    write(pty.master, "mkdir -p \$prefix/{lib,bin}\n")
    write(pty.master, "cp fooifier \$prefix/bin\n")
    write(pty.master, "cp libfoo.so \$prefix/lib\n")
    write(pty.master, "exit\n")
    readuntil(pty.master, "Would you like to edit this script now?")
    write(pty.master, "N\n")
    # Step 4
    write(pty.master, "ad")
    write(pty.master, "libfoo\nfooifier\n")
    wait(t)
end

# Step 3 failure path (no binary in destdir -> start over)
let state = BinaryBuilder.WizardState(ins, outs)
    state.step = :step3
    state.source_urls = ["http://127.0.0.1:14444/a/source.tar.gz\n"]
    state.source_files = [joinpath(tempspace, "source.tar.gz")]
    state.source_hashes = [bytes2hex(tar_hash)]
    state.platforms = [Linux(:x86_64)]
    t = @async do_try(()->while state.step == :step3
        BinaryBuilder.step34(state)
    end)
    write(pty.master, "cd libfoo/\n")
    write(pty.master, "make install\n")
    write(pty.master, "rm -rf \$prefix/*\n")
    write(pty.master, "exit\n")
    readuntil(pty.master, "Would you like to edit this script now?")
    write(pty.master, "N\n")
    # How would you like to proceed
    wait_for_menu(pty)
    write(pty.master, "\e[B")
    sleep(1)
    write(pty.master, "\r")
    wait_for_non_menu(pty)
    write(pty.master, "cd libfoo/\n")
    write(pty.master, "make install\n")
    write(pty.master, "exit\n")
    readuntil(pty.master, "Would you like to edit this script now?")
    write(pty.master, "N\n")
    # Step 4
    write(pty.master, "ad")
    write(pty.master, "libfoo\nfooifier\n")
    wait(t)
end

# Step 7 testing
let state = BinaryBuilder.WizardState(ins, outs)
    state.step = :step7
    state.source_urls = ["http://julialang.org/"]
    state.source_files = ["./julia.tar.gz"]
    state.source_hashes = ["0"^64]
    state.history = ""
    state.files = ["libjulia"]
    state.file_kinds = [:library]
    state.file_varnames = [:libjulia]
    state.dependencies = []
    state.platforms = [Linux(:x86_64)]

    t = @async do_try(()->BinaryBuilder.step7(state))
    sleep(1)

    # Write first project name (ensuring it fails gracefully), then project version:
    readuntil(pty.master, "Enter a name for this project.")
    readuntil(pty.master, "This will be used for filenames:")
    readuntil(pty.master, "> ")
    write(pty.master, "\r")
    readuntil(pty.master, "Name may not be empty!")
    readuntil(pty.master, "This will be used for filenames:")
    readuntil(pty.master, "> ")
    write(pty.master, "ProjectName\r")

    readuntil(pty.master, "Enter a version number for this project.")
    readuntil(pty.master, "This will be used for filenames:")
    readuntil(pty.master, "> ")
    write(pty.master, "v1.2.3\r")

    # We should get a build_tarballs.jl spat out now, which ends somewhere around "build_tarballs(...)"
    readuntil(pty.master, "build_tarballs(")

    # We should also get a .travis.yml, which ends somewhere around " - julia build_tarballs.jl"
    readuntil(pty.master, " - julia build_tarballs.jl")

    # Let's not test script deployment
    readuntil(pty.master, "May I help you with the deployment of these scripts?")
    wait_for_menu(pty)
    write(pty.master, "\e[B")
    sleep(1)
    write(pty.master, "\e[B")
    sleep(1)
    write(pty.master, "\r")

    # Now wait for that task to finish itself up
    wait(t)
end

struct GitHubSimulator <: GitHub.GitHubAPI
end

function GitHub.gh_post(g::GitHubSimulator, endpoint; auth = nothing, headers = Dict(), kwargs...)
    if endpoint == "/authorizations"
        @test isa(auth, GitHub.UsernamePassAuth)
        @test auth.username == "TestUser"
        @test auth.password == "test"
        # Simulate 2FA enabled
        if !haskey(headers, "X-GitHub-OTP")
            return HTTP.Response(401, Dict("X-GitHub-OTP"=>"required"))
        else
            return HTTP.Response(200; body=Vector{UInt8}("""
            {
              "id": 1,
              "url": "https://api.github.com/authorizations/1",
              "scopes": [
                "public_repo"
              ],
              "token": "abcdefgh12345678",
              "token_last_eight": "12345678",
              "hashed_token": "25f94a2a5c7fbaf499c665bc73d67c1c87e496da8985131633ee0a95819db2e8",
              "app": {
                "url": "http://my-github-app.com",
                "name": "my github app",
                "client_id": "abcde12345fghij67890"
              },
              "note": "optional note",
              "note_url": "http://optional/note/url",
              "updated_at": "2011-09-06T20:39:23Z",
              "created_at": "2011-09-06T17:26:27Z",
              "fingerprint": ""
            }
            """))
        end
    else
        error()
    end
end

push_counter = 0
create_repo_counter = 0
function BinaryBuilder.push_repo(g::GitHubSimulator, args...)
    global push_counter += 1
end
function GitHub.create_repo(api::GitHubSimulator, owner, name::String, params=Dict{String,Any}(); kwargs...)
    global create_repo_counter += 1
    GitHub.Repo("TestUser/TestRepo")
end

function emulate_travis(req)
    if req.target == "/travis/auth/github"
        HTTP.Response(200; body=Vector{UInt8}("""
        {"access_token":"some_token"}
        """))
    elseif req.target == "/travis/users/sync"
        HTTP.Response(200)
    elseif req.target == "/travis/repos/TestUser/TestRepo"
        HTTP.Response(200; body=Vector{UInt8}("""
        {
          "repo": {
            "id": 1,
            "slug": "TestUser/TestRepo",
            "description": "Whatever",
            "last_build_id": 23436881,
            "last_build_number": "792",
            "last_build_state": "passed",
            "last_build_duration": 2542,
            "last_build_started_at": "2014-04-21T15:27:14Z",
            "last_build_finished_at": "2014-04-21T15:40:04Z",
            "active": "true"
          }
        }
        """))
    elseif req.target == "/travis/repo/1/activate"
        HTTP.Response(200)
    elseif req.target == "/travis/repos/TestUser/TestRepo/key"
        HTTP.Response(200; body=Vector{UInt8}("""
        {"key":"-----BEGIN PUBLIC KEY-----\\n"""*
        "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA88f8L8L5XhApAf0WC3VQ\\n"*
        "AdA2x6ZBB6flQ7/xbhFOIHgK2zX+GT1kvr5BrrKjscD1/pNm13LMXeBD/R+PlcTo\\n"*
        "hAJYAxbeniTD//Zkx6mocCmqkNjpp7N6i1HOmls/vWvs3c4ZrZpy9hWk70MOH1j3\\n"*
        "VXxDuugfWkTiq6GExLrTRaVLe0qagL0goIHSTdpJbyWxOct3+W8bv8v/scwqmnQf\\n"*
        "ecjGYRjEqAXWYQLTJ+VY2zRGcksESztykfgA9Hj/CH0Jh5wE43hUXa61CEdseQ7P\\n"*
        "QtMX8OPzcu2QWOoSHHnv6Q0Tte7xc+TKG3h3KC2DW/x2qog5RsXMh2UJXsLG+iDv\\n"*
        "tYidlyekxcmldbpNm7169CnjRa3Kq55vIwtRiMPTcLbrMwzi1aJWOBVPthfDTu//\\n"*
        "6HM3ajzZIo6xmg5lddBB09jsY5uoqdu5ddKAo9Wkeqn/gYzQrHyc7jvLMDo7RPFp\\n"*
        "ZnY8u2tWFYK/O1LonqJY3Oyf4ZS2aKDTciVoNSBIqJzAgC2LF1E8WEBMcmFy4xeB\\n"*
        "4Ke2j6bF+szTnKbcRTHhu9AvSkDdWxN3JFolGNHYnIHD0jNlc3rlTSkQfzCFgP3U\\n"*
        "9RQRgz6ix3lP608gL0j64GuSFuIqulmn9UiKgf8J8eV9FLybbZ1WayBe8Bbfbh3c\\n"*
        "y7a79CxhXJ0WJxO5pQijKXkCAwEAAQ==\\n"*
        """-----END PUBLIC KEY-----\\n",
        "fingerprint":"e3:5c:d0:0d:d8:00:bb:6d:fb:c2:e7:9b:59:9f:91:50"}
        """))
    else
        error()
    end
end
HTTP.register!(r, "/travis/*", HTTP.HandlerFunction(emulate_travis))

# Test GitHub Deploy
let state = BinaryBuilder.WizardState(ins, outs)
    state.step = :step7
    state.source_urls = ["http://127.0.0.1:14444/a/source.tar.gz\n"]
    state.source_files = [joinpath(tempspace, "source.tar.gz")]
    state.source_hashes = [bytes2hex(tar_hash)]
    state.github_api = GitHubSimulator()
    state.files = String[]
    state.file_kinds = Symbol[]
    state.file_varnames = Symbol[]
    state.platforms = [Linux(:x86_64)]
    state.name = "Test"
    state.version = v"1.2.3"
    state.history = ""
    state.travis_endpoint = "http://127.0.0.1:14444/travis/"

    git_cfg = LibGit2.GitConfig(joinpath(tempspace, ".gitconfig"))
    LibGit2.set!(git_cfg, "user.name", "TestUser")
    LibGit2.set!(git_cfg, "github.user", "TestUser")
    LibGit2.set!(git_cfg, "user.email", "test@user.email")

    t = @async do_try(()->BinaryBuilder.github_deploy(state; git_cfg=git_cfg))
    readuntil(pty.master, "Enter the desired name for the new repository: ")
    write(pty.master, "TestRepo\n")
    readuntil(pty.master, "Please enter the github.com password for TestUser:")
    write(pty.master, "test\n")
    readuntil(pty.master, "Two factor authentication in use.  Enter auth code.")
    write(pty.master, "12345\n")
    readuntil(pty.master, "Enter your desired license [MIT]: ")
    write(pty.master, "\n")
    readuntil(pty.master, "Deployment Complete")

    wait(t)
end

# We're done with the server
put!(server.in, HTTP.Servers.KILL)
rm(tempspace; force=true, recursive=true)

end #if

ext: jl


text:
using OpenStreetMap
mapFile = "Cities/Manhattan/manhattan-raw.osm"
cd("/Users/Sebastien/Documents/Dropbox (MIT)/Research/Taxi/JuliaSimulation")
@time nodes, hwys, builds, feats = getOSMData(mapFile)
length(nodes),  length(hwys)

(40.6780 + 40.8860)/2
(-74.0382 -73.9030)/2
bounds = Bounds(40.6780, 40.8860, -74.0382, -73.9030)
center(bounds)
boundsENU = ENU(bounds)
nodesENU = ENU(nodes,center(bounds))
typeof(nodesENU)
highway_sets = findHighwaySets(hwys)
intersections = findIntersections(hwys)

@time intersection_cluster_mapping = findIntersectionClusters(nodesENU,intersections,highway_sets,max_dist=15)
replaceHighwayNodes!(hwys,intersection_cluster_mapping)
intersections = findIntersections(hwys)
roads = roadways(hwys)

segments = segmentHighways(nodesENU, hwys, intersections, roads, Set(1:7))
network = createGraph(segments, intersections)
network_rev = createGraph(segments, intersections, true)

stdin, proc = open(`neato -n2 -Tpng -o graph.png`, "w")
drawGraph(network.g,stdin)
close(stdin)

bell = bellman_ford_shortest_paths(network.g, network.w, [vertices(network.g)[4578]])
bell_rev = bellman_ford_shortest_paths(network_rev.g, network_rev.w, [vertices(network_rev.g)[4578]])

remove_nodes = Int[]
for (i,d) in enumerate(bell.dists)
  if d == Inf || bell_rev.dists[i] == Inf
    push!(remove_nodes,vertices(network.g)[i].key)
  end
end

network2 = remove_vertices(remove_nodes, segments, intersections, false)
network2_rev = remove_vertices(remove_nodes, segments, intersections, true)

stdin, proc = open(`neato -n2 -Tpng -o graph.png`, "w")
drawGraph(network2.g,stdin)
close(stdin)

bridgestemp = [7662, 14968, 10656, 8172, 20606, 15545, 548, 20992, 2817, 925,
8468,16867, 3980, 17750, 13346, 4776, 17154, 5077, 20065, 1531, 18815, 2626,
13486,8829,14829,12088, 11932, 17513, 9236, 18627, 438, 217, 8064, 14962, 20985,
9664, 11434, 21266, 12592, 12357, 3571, 17112, 20865]
bridges = [vertices(network2.g)[i].key for i in bridgestemp]
append!(remove_nodes, bridges)

network3 = remove_vertices(remove_nodes, segments, intersections, false)
network3_rev = remove_vertices(remove_nodes, segments, intersections, true)

stdin, proc = open(`neato -n2 -Tpng -o graph.png`, "w")
drawGraph(network3.g,stdin)
close(stdin)

bell2 = bellman_ford_shortest_paths(network3.g, network3.w, [vertices(network3.g)[19624]])
bell2_rev = bellman_ford_shortest_paths(network3_rev.g, network3_rev.w, [vertices(network3_rev.g)[19624]])

remove_nodes2 = Int[]
for (i,d) in enumerate(bell2.dists)
  if d == Inf || bell2_rev.dists[i] == Inf
    push!(remove_nodes2, remove_nodes, vertices(network3.g)[i].key)
  end
end
append!(remove_nodes2, remove_nodes)
network4 = remove_vertices(remove_nodes2, segments, intersections)

stdin, proc = open(`neato -n2 -Tpng -o graph.png`, "w")
drawGraph(network4.g,stdin)
close(stdin)

using HDF5, JLD

length(nodesENU)
length(remove_nodes)
nodes = Int[]
for i in vertices(network4.g)
  push!(nodes, i.key)
end
length(nodes)
ENUbis = Dict{Int64,ENU}()
for i in nodes
    ENUbis[i] = nodesENU[i]
end
save("Cities/Manhattan/manhattan.jld", "network", network4,"nodes", ENUbis)

bridges2 = [6155, 3595, 14218, 2148]
bridges2 = Int[vertices(network4.g)[i].key for i in bridges2]

remove_nodes3 = [remove_nodes2, bridges2]::Vector{Int}
network5 = remove_vertices(remove_nodes3, segments, intersections, false)
network5_rev = remove_vertices(remove_nodes3, segments, intersections, true)

stdin, proc = open(`neato -n2 -Tpng -o graph.png`, "w")
drawGraph(network5.g,stdin)
close(stdin)

bell3 = bellman_ford_shortest_paths(network5.g, network5.w, [vertices(network5.g)[4323]])
bell3_rev = bellman_ford_shortest_paths(network5_rev.g, network5_rev.w, [vertices(network5_rev.g)[4323]])

remove_nodes4 = Int[]
for (i,d) in enumerate(bell3.dists)
  if d == Inf || bell3_rev.dists[i] == Inf
    push!(remove_nodes4,vertices(network5.g)[i].key)
  end
end
append!(remove_nodes4, remove_nodes3)
network6 = remove_vertices(remove_nodes4, segments, intersections)

using HDF5, JLD
save("New_York/manhattan.jld", network6)

stdin, proc = open(`neato -n2 -Tpdf -o graph.pdf`, "w")
drawGraph(network6.g,stdin)
close(stdin)

num_vertices(network6.g)

function drawGraph{G<:AbstractGraph}(graph::G, stream::IO)
    has_vertex_attrs = method_exists(attributes, (vertex_type(graph), G))
    has_edge_attrs = method_exists(attributes, (edge_type(graph), G))

    write(stream, "digraph  graphname {\n")

  if implements_edge_list(graph) && implements_vertex_map(graph)
        for edge in edges(graph)
            write(stream, "$(vertex_index(source(edge), graph)) $(edge_op(graph)) $(vertex_index(target(edge), graph))\n")
        end
    elseif implements_vertex_list(graph) && (implements_incidence_list(graph) || implements_adjacency_list(graph))
        for vertex in vertices(graph)
            id = vertex_index(vertex, graph)
            east = nodesENU[vertex.key].east
            north = nodesENU[vertex.key].north
            attr = "\"pos\"=\"$east,$(north)!\""
            write(stream, "$id [$attr]\n")

            if implements_incidence_list(graph)
                for e in out_edges(vertex, graph)
                    n = target(e, graph)
                    if is_directed(graph) || vertex_index(n, graph) > vertex_index(vertex, graph)
                        write(stream, "$(vertex_index(vertex, graph)) -> $(vertex_index(n, graph))$(has_edge_attrs ? string(" ", to_dot(attributes(e, graph))) : "")\n")
                    end
                end
            end
        end
    else
        throw(ArgumentError("More graph Concepts needed: dot serialization requires iteration over edges or iteration over vertices and neighbors."))
    end
    write(stream, "}\n")
    stream
end

function remove_vertices(remInd, segments, intersections, rev=false)
    v = Dict{Int,Graphs.KeyVertex{Int}}()                       # Vertices
    w = Float64[]                                               # Weights
    class = Int[]                                               # Road class
    g = Graphs.inclist(Graphs.KeyVertex{Int}, is_directed=true) # Graph

    for vert in keys(intersections)
      if !in(vert, remInd)
        v[vert] = Graphs.add_vertex!(g, vert)
      end
    end

    for segment in segments
        # Add edges to graph and compute weights
        if rev
          node0 = segment.node1
          node1 = segment.node0
        else
          node0 = segment.node0
          node1 = segment.node1
        end
        if !in(node0, remInd) &&  !in(node1, remInd)
          edge = Graphs.make_edge(g, v[node0], v[node1])
          Graphs.add_edge!(g, edge)
          weight = segment.dist
          push!(w, weight)
          push!(class, segment.class)
          node_set = Set(node0, node1)

          if !segment.oneway
              edge = Graphs.make_edge(g, v[node1], v[node0])
              Graphs.add_edge!(g, edge)
              push!(w, weight)
              push!(class, segment.class)
          end
      end
    end

    return OpenStreetMap.Network(g, v, w, class)

end

#---------------------------------------------------
#-- CONSTRUCTION GRAPH
#---------------------------------------------------

data = load("Cities/Manhattan/manhattan_raw.jld")

idToVertex = data["network"].v
oldGraph   = data["network"].g
nodes = data["nodes"]
w = data["network"].w

graphMan = LightGraphs.DiGraph(num_vertices(oldGraph))

for i in vertices(oldGraph), j in Set( out_neighbors(i,oldGraph))
  LightGraphs.add_edge!(graphMan, i.index, j.index)
end

weights = spzeros(num_vertices(oldGraph),num_vertices(oldGraph))
times   = spzeros(num_vertices(oldGraph),num_vertices(oldGraph))
positions = [(0.0,0.0) for i in 1:num_vertices(oldGraph)]

for i in vertices(oldGraph), e in Set( out_edges(i,oldGraph))
  weights[ i.index, target(e).index] = w[e.index]
  times[ i.index, target(e).index] = 3.6*w[e.index]/OpenStreetMap.SPEED_ROADS_URBAN[data["network"].class[e.index]]
end

for i in vertices(oldGraph)
  positions[i.index] = (nodes[i.key].east, nodes[i.key].north)
end

save("Cities/Manhattan/manhattan.jld", "network", graphMan, "distances", weights, "timings", times, "positions", positions)

max_stars_repo_name: semartin/TaxiDataExtraction

max_issues_repo_name: ericytung/TaxiDataTools

max_forks_repo_name: ericytung/TaxiDataTools