AndreasAhrens.se


Views, guides, tech stuff, Cryptocurrencies and ICOs from the mind of Andreas Ahrens

Tags


AndreasAhrens.se

seeds.rb for countries of the world in Ruby

10th February 2016

Today I needed to seed a Ruby DB with all the countries in the world, something that would be a rather hard task to complete manually. So I created a simple Google Spreadsheet that created it automatically. Below is my code, but you can input your own model name and column names if you [make a copy](https://docs.google.com/spreadsheets/d/1lDFf11tp1rQ7C3GjC0pMnmwsztNRu24lh36uEwjXy9Y/copy " target="_blank ) of [my spreadsheet](https://docs.google.com/spreadsheets/d/1lDFf11tp1rQ7C3GjC0pMnmwsztNRu24lh36uEwjXy9Y/edit?usp=sharing " target="_blank ).

country1 = Country.create(name: "Afghanistan", region: "Asia")
country2 = Country.create(name: "Albania", region: "Europe")
country3 = Country.create(name: "Algeria", region: "Africa")
country4 = Country.create(name: "American Samoa", region: "Australasia")
country5 = Country.create(name: "Andorra", region: "Europe")
country6 = Country.create(name: "Angola", region: "Africa")
country7 = Country.create(name: "Anguilla", region: "Caribbean")
country8 = Country.create(name: "Antigua and Barbuda", region: "Caribbean")
country9 = Country.create(name: "Argentina", region: "South America")
country10 = Country.create(name: "Armenia", region: "Europe")
country11 = Country.create(name: "Aruba", region: "Caribbean")
country12 = Country.create(name: "Australia", region: "Australasia")
country13 = Country.create(name: "Austria", region: "Europe")
country14 = Country.create(name: "Azerbaijan", region: "Europe")
country15 = Country.create(name: "Bahamas", region: "Caribbean")
country16 = Country.create(name: "Bahrain", region: "Middle East")
country17 = Country.create(name: "Bangladesh", region: "Asia")
country18 = Country.create(name: "Barbados", region: "Caribbean")
country19 = Country.create(name: "Belarus", region: "Europe")
country20 = Country.create(name: "Belgium", region: "Europe")
country21 = Country.create(name: "Belize", region: "North America")
country22 = Country.create(name: "Benin", region: "Africa")
country23 = Country.create(name: "Bermuda", region: "Caribbean")
country24 = Country.create(name: "Bhutan", region: "Asia")
country25 = Country.create(name: "Bolivia", region: "South America")
country26 = Country.create(name: "Bonaire", region: "Caribbean")
country27 = Country.create(name: "Bosnia-Herzegovina", region: "Europe")
country28 = Country.create(name: "Botswana", region: "Africa")
country29 = Country.create(name: "Bouvet Island", region: "Africa")
country30 = Country.create(name: "Brazil", region: "South America")
country31 = Country.create(name: "Brunei", region: "Asia")
country32 = Country.create(name: "Bulgaria", region: "Europe")
country33 = Country.create(name: "Burkina Faso", region: "Africa")
country34 = Country.create(name: "Burundi", region: "Africa")
country35 = Country.create(name: "Cambodia", region: "Asia")
country36 = Country.create(name: "Cameroon", region: "Africa")
country37 = Country.create(name: "Canada", region: "North America")
country38 = Country.create(name: "Cape Verde", region: "Africa")
country39 = Country.create(name: "Cayman Islands", region: "Caribbean")
country40 = Country.create(name: "Central African Republic", region: "Africa")
country41 = Country.create(name: "Chad", region: "Africa")
country42 = Country.create(name: "Chile", region: "South America")
country43 = Country.create(name: "China", region: "Asia")
country44 = Country.create(name: "Christmas Island", region: "Australasia")
country45 = Country.create(name: "Cocos (Keeling) Islands", region: "Australasia")
country46 = Country.create(name: "Colombia", region: "South America")
country47 = Country.create(name: "Comoros", region: "Africa")
country48 = Country.create(name: "Congo, Democratic Republic of the (Zaire)", region: "Africa")
country49 = Country.create(name: "Congo, Republic of", region: "Africa")
country50 = Country.create(name: "Cook Islands", region: "Australasia")
country51 = Country.create(name: "Costa Rica", region: "North America")
country52 = Country.create(name: "Croatia", region: "Europe")
country53 = Country.create(name: "Cuba", region: "Caribbean")
country54 = Country.create(name: "Curacao", region: "Caribbean")
country55 = Country.create(name: "Cyprus", region: "Europe")
country56 = Country.create(name: "Czech Republic", region: "Europe")
country57 = Country.create(name: "Denmark", region: "Europe")
country58 = Country.create(name: "Djibouti", region: "Africa")
country59 = Country.create(name: "Dominica", region: "Caribbean")
country60 = Country.create(name: "Dominican Republic", region: "Caribbean")
country61 = Country.create(name: "Ecuador", region: "South America")
country62 = Country.create(name: "Egypt", region: "Africa")
country63 = Country.create(name: "El Salvador", region: "North America")
country64 = Country.create(name: "Equatorial Guinea", region: "Africa")
country65 = Country.create(name: "Eritrea", region: "Africa")
country66 = Country.create(name: "Estonia", region: "Europe")
country67 = Country.create(name: "Ethiopia", region: "Africa")
country68 = Country.create(name: "Falkland Islands", region: "South America")
country69 = Country.create(name: "Faroe Islands", region: "Europe")
country70 = Country.create(name: "Fiji", region: "Australasia")
country71 = Country.create(name: "Finland", region: "Europe")
country72 = Country.create(name: "France", region: "Europe")
country73 = Country.create(name: "French Guiana", region: "South America")
country74 = Country.create(name: "Gabon", region: "Africa")
country75 = Country.create(name: "Gambia", region: "Africa")
country76 = Country.create(name: "Georgia", region: "Europe")
country77 = Country.create(name: "Germany", region: "Europe")
country78 = Country.create(name: "Ghana", region: "Africa")
country79 = Country.create(name: "Gibraltar", region: "Europe")
country80 = Country.create(name: "Greece", region: "Europe")
country81 = Country.create(name: "Greenland", region: "Europe")
country82 = Country.create(name: "Grenada", region: "Caribbean")
country83 = Country.create(name: "Guadeloupe (French)", region: "Caribbean")
country84 = Country.create(name: "Guam (USA)", region: "Australasia")
country85 = Country.create(name: "Guatemala", region: "North America")
country86 = Country.create(name: "Guinea", region: "Africa")
country87 = Country.create(name: "Guinea Bissau", region: "Africa")
country88 = Country.create(name: "Guyana", region: "South America")
country89 = Country.create(name: "Haiti", region: "Caribbean")
country90 = Country.create(name: "Holy See", region: "Europe")
country91 = Country.create(name: "Honduras", region: "North America")
country92 = Country.create(name: "Hong Kong", region: "Asia")
country93 = Country.create(name: "Hungary", region: "Europe")
country94 = Country.create(name: "Iceland", region: "Europe")
country95 = Country.create(name: "India", region: "Asia")
country96 = Country.create(name: "Indonesia", region: "Asia")
country97 = Country.create(name: "Iran", region: "Middle East")
country98 = Country.create(name: "Iraq", region: "Middle East")
country99 = Country.create(name: "Ireland", region: "Europe")
country100 = Country.create(name: "Israel", region: "Middle East")
country101 = Country.create(name: "Italy", region: "Europe")
country102 = Country.create(name: "Ivory Coast (Cote D`Ivoire)", region: "Africa")
country103 = Country.create(name: "Jamaica", region: "Caribbean")
country104 = Country.create(name: "Japan", region: "Asia")
country105 = Country.create(name: "Jordan", region: "Middle East")
country106 = Country.create(name: "Kazakhstan", region: "Asia")
country107 = Country.create(name: "Kenya", region: "Africa")
country108 = Country.create(name: "Kiribati", region: "Australasia")
country109 = Country.create(name: "Kosovo", region: "Europe")
country110 = Country.create(name: "Kuwait", region: "Middle East")
country111 = Country.create(name: "Kyrgyzstan", region: "Asia")
country112 = Country.create(name: "Laos", region: "Asia")
country113 = Country.create(name: "Latvia", region: "Europe")
country114 = Country.create(name: "Lebanon", region: "Middle East")
country115 = Country.create(name: "Lesotho", region: "Africa")
country116 = Country.create(name: "Liberia", region: "Africa")
country117 = Country.create(name: "Libya", region: "Africa")
country118 = Country.create(name: "Liechtenstein", region: "Europe")
country119 = Country.create(name: "Lithuania", region: "Europe")
country120 = Country.create(name: "Luxembourg", region: "Europe")
country121 = Country.create(name: "Macau", region: "Asia")
country122 = Country.create(name: "Macedonia", region: "Europe")
country123 = Country.create(name: "Madagascar", region: "Africa")
country124 = Country.create(name: "Malawi", region: "Africa")
country125 = Country.create(name: "Malaysia", region: "Asia")
country126 = Country.create(name: "Maldives", region: "Asia")
country127 = Country.create(name: "Mali", region: "Africa")
country128 = Country.create(name: "Malta", region: "Europe")
country129 = Country.create(name: "Marshall Islands", region: "Australasia")
country130 = Country.create(name: "Martinique (French)", region: "Caribbean")
country131 = Country.create(name: "Mauritania", region: "Africa")
country132 = Country.create(name: "Mauritius", region: "Africa")
country133 = Country.create(name: "Mayotte", region: "Africa")
country134 = Country.create(name: "Mexico", region: "North America")
country135 = Country.create(name: "Micronesia", region: "Australasia")
country136 = Country.create(name: "Moldova", region: "Europe")
country137 = Country.create(name: "Monaco", region: "Europe")
country138 = Country.create(name: "Mongolia", region: "Asia")
country139 = Country.create(name: "Montenegro", region: "Europe")
country140 = Country.create(name: "Montserrat", region: "Caribbean")
country141 = Country.create(name: "Morocco", region: "Africa")
country142 = Country.create(name: "Mozambique", region: "Africa")
country143 = Country.create(name: "Myanmar", region: "Asia")
country144 = Country.create(name: "Namibia", region: "Africa")
country145 = Country.create(name: "Nauru", region: "Australasia")
country146 = Country.create(name: "Nepal", region: "Asia")
country147 = Country.create(name: "Netherlands", region: "Europe")
country148 = Country.create(name: "Netherlands Antilles", region: "Caribbean")
country149 = Country.create(name: "New Caledonia (French)", region: "Australasia")
country150 = Country.create(name: "New Zealand", region: "Australasia")
country151 = Country.create(name: "Nicaragua", region: "North America")
country152 = Country.create(name: "Niger", region: "Africa")
country153 = Country.create(name: "Nigeria", region: "Africa")
country154 = Country.create(name: "Niue", region: "Australasia")
country155 = Country.create(name: "Norfolk Island", region: "Australasia")
country156 = Country.create(name: "North Korea", region: "Asia")
country157 = Country.create(name: "Northern Mariana Islands", region: "Asia")
country158 = Country.create(name: "Norway", region: "Europe")
country159 = Country.create(name: "Oman", region: "Middle East")
country160 = Country.create(name: "Pakistan", region: "Asia")
country161 = Country.create(name: "Palau", region: "Australasia")
country162 = Country.create(name: "Panama", region: "North America")
country163 = Country.create(name: "Papua New Guinea", region: "Australasia")
country164 = Country.create(name: "Paraguay", region: "South America")
country165 = Country.create(name: "Peru", region: "South America")
country166 = Country.create(name: "Philippines", region: "Asia")
country167 = Country.create(name: "Pitcairn Island", region: "Australasia")
country168 = Country.create(name: "Poland", region: "Europe")
country169 = Country.create(name: "Polynesia (French)", region: "Australasia")
country170 = Country.create(name: "Portugal", region: "Europe")
country171 = Country.create(name: "Puerto Rico", region: "Caribbean")
country172 = Country.create(name: "Qatar", region: "Middle East")
country173 = Country.create(name: "Reunion", region: "Africa")
country174 = Country.create(name: "Romania", region: "Europe")
country175 = Country.create(name: "Russia", region: "Europe")
country176 = Country.create(name: "Rwanda", region: "Africa")
country177 = Country.create(name: "Saint Helena", region: "Africa")
country178 = Country.create(name: "Saint Kitts and Nevis", region: "Caribbean")
country179 = Country.create(name: "Saint Lucia", region: "Caribbean")
country180 = Country.create(name: "Saint Pierre and Miquelon", region: "North     America")
country181 = Country.create(name: "Saint Vincent and Grenadines", region:     "Caribbea    n")
country182 = Country.create(name: "Samoa", region: "Australasia")
country183 = Country.create(name: "San Marino", region: "Europe")
country184 = Country.create(name: "Sao Tome and Principe", region: "Africa")
country185 = Country.create(name: "Saudi Arabia", region: "Middle East")
country186 = Country.create(name: "Senegal", region: "Africa")
country187 = Country.create(name: "Serbia", region: "Europe")
country188 = Country.create(name: "Seychelles", region: "Africa")
country189 = Country.create(name: "Sierra Leone", region: "Africa")
country190 = Country.create(name: "Singapore", region: "Asia")
country191 = Country.create(name: "Sint Maarten", region: "Caribbean")
country192 = Country.create(name: "Slovakia", region: "Europe")
country193 = Country.create(name: "Slovenia", region: "Europe")
country194 = Country.create(name: "Solomon Islands", region: "Australasia")
country195 = Country.create(name: "Somalia", region: "Africa")
country196 = Country.create(name: "South Africa", region: "Africa")
country197 = Country.create(name: "South Georgia and South Sandwich Islands", region: "South America")
country198 = Country.create(name: "South Korea", region: "Asia")
country199 = Country.create(name: "South Sudan", region: "Africa")
country200 = Country.create(name: "South Sudan", region: "Africa")
country201 = Country.create(name: "Spain", region: "Europe")
country202 = Country.create(name: "Sri Lanka", region: "Asia")
country203 = Country.create(name: "Sudan", region: "Africa")
country204 = Country.create(name: "Suriname", region: "South America")
country205 = Country.create(name: "Svalbard and Jan Mayen Islands", region: "Europe")
country206 = Country.create(name: "Swaziland", region: "Africa")
country207 = Country.create(name: "Sweden", region: "Europe")
country208 = Country.create(name: "Switzerland", region: "Europe")
country209 = Country.create(name: "Syria", region: "Middle East")
country210 = Country.create(name: "Taiwan", region: "Asia")
country211 = Country.create(name: "Tajikistan", region: "Asia")
country212 = Country.create(name: "Tanzania", region: "Africa")
country213 = Country.create(name: "Thailand", region: "Asia")
country214 = Country.create(name: "Timor-Leste (East Timor)", region: "Australasia")
country215 = Country.create(name: "Togo", region: "Africa")
country216 = Country.create(name: "Tokelau", region: "Australasia")
country217 = Country.create(name: "Tonga", region: "Australasia")
country218 = Country.create(name: "Trinidad and Tobago", region: "Caribbean")
country219 = Country.create(name: "Tunisia", region: "Africa")
country220 = Country.create(name: "Turkey", region: "Middle East")
country221 = Country.create(name: "Turkmenistan", region: "Asia")
country222 = Country.create(name: "Turks and Caicos Islands", region: "Caribbean")
country223 = Country.create(name: "Tuvalu", region: "Australasia")
country224 = Country.create(name: "Uganda", region: "Africa")
country225 = Country.create(name: "Ukraine", region: "Europe")
country226 = Country.create(name: "United Arab Emirates", region: "Middle East")
country227 = Country.create(name: "United Kingdom", region: "Europe")
country228 = Country.create(name: "United States", region: "North America")
country229 = Country.create(name: "Uruguay", region: "South America")
country230 = Country.create(name: "Uzbekistan", region: "Asia")
country231 = Country.create(name: "Vanuatu", region: "Australasia")
country232 = Country.create(name: "Venezuela", region: "South America")
country233 = Country.create(name: "Vietnam", region: "Asia")
country234 = Country.create(name: "Virgin Islands", region: "Caribbean")
country235 = Country.create(name: "Wallis and Futuna Islands", region: "Australasia")
country236 = Country.create(name: "Yemen", region: "Middle East")
country237 = Country.create(name: "Zambia", region: "Africa")
country238 = Country.create(name: "Zimbabwe", region: "Africa")

View Comments