mledoze/countries

repository·master·Indexed 27 days ago

https://github.com/mledoze/countries

A comprehensive dataset of world countries based on the ISO 3166-1 standard, providing standardized information in JSON, CSV, XML, and YAML formats. The dataset includes details such as names, ISO codes, currency, calling codes, geographical data, and UN membership. It also provides GeoJSON outlines and SVG flags. Version 5.1.0.

Tokens
3.3K
Snippets
3
Records
16
Agent score
92%

What's inside mledoze-countries

  1. Overview of World Countries Data

    master

    This project provides a comprehensive dataset of world countries based on the ISO 3166-1 standard. The data is available in JSON, CSV, XML, and YAML formats. It includes detailed information such as names, ISO codes, currency details, calling codes, and geographical data.

    Note: Not all entities in the dataset are sovereign states. To identify if an entity is a sovereign state, check the independent property.

  2. Install dependencies for custom data builds

    master
    To build a custom version of the country data, you must have a working PHP installation and Composer installed. Navigate to the root directory of the local repository and run composer install to set up the required dependencies.
    composer install
  3. View XML country data examples

    master

    The project provides country data in XML format. In the XML structure, nested JSON properties are represented as attributes on the <country> element using dot-notation (e.g., name.native.nld.official="Aruba").

    <?xml version="1.0" encoding="UTF-8"?>
    <countries>
      <country name.common="Aruba" name.official="Aruba" name.native.nld.official="Aruba" name.native.nld.common="Aruba" name.native.pap.official="Aruba" name.native.pap.common="Aruba" tld=".aw" cca2="AW" ccn3="533" cca3="ABW" cioc="ARU" independent="0" status="officially-assigned" unMember="0" currencies.AWG.name="Aruban florin" currencies.AWG.symbol="ƒ" idd.root="+2" idd.suffixes="97" capital="Oranjestad" altSpellings="AW" region="Americas" subregion="Caribbean" languages.nld="Dutch" languages.pap="Papiamento" translations.ces.official="Aruba" translations.ces.common="Aruba" translations.deu.official="Aruba" translations.deu.common="Aruba" translations.est.official="Aruba" translations.est.common="Aruba" translations.fin.official="Aruba" translations.fin.common="Aruba" translations.fra.official="Aruba" translations.fra.common="Aruba" translations.hrv.official="Aruba" translations.hrv.common="Aruba" translations.hun.official="Aruba" translations.hun.common="Aruba" translations.ita.official="Aruba" translations.ita.common="Aruba" translations.jpn.official="アルバ" translations.jpn.common="アルバ" translations.kor.official="아루바" translations.kor.common="아루바" translations.nld.official="Aruba" translations.nld.common="Aruba" translations.per.official="آروبا" translations.per.common="آروبا" translations.pol.official="Aruba" translations.pol.common="Aruba" translations.por.official="Aruba" translations.por.common="Aruba" translations.rus.official="Аруба" translations.rus.common="Аруба" translations.slk.official="Aruba" translations.slk.common="Aruba" translations.spa.official="Aruba" translations.spa.common="Aruba" translations.swe.official="Aruba" translations.swe.common="Aruba" translations.urd.official="اروبا" translations.urd.common="اروبا" translations.zho.official="阿鲁巴" translations.zho.common="阿鲁巴" latlng="12.5,-69.96666666" landlocked="0" borders="" area="180" flag="🇦🇼" demonyms.eng.f="Aruban" demonyms.eng.m="Aruban" demonyms.fra.f="Arubaise" demonyms.fra.m="Arubais" callingCodes="+297"/>
    </countries>
  4. View JSON country data examples

    master

    The project provides comprehensive country data in JSON format. Each object includes details such as names (common, official, native), TLDs, ISO codes (cca2, cca3, ccn3), status, UN membership, currencies, calling codes, capital, region, subregion, languages, translations, coordinates (latlng), landlocked status, borders, area, and flags.

    {
    	"name": {
    		"common": "Austria",
    		"official": "Republic of Austria",
    		"native": {
    			"bar": {
    				"official": "Republik Österreich",
    				"common": "Österreich"
    			}
    		}
    	},
    	"tld": [".at"],
    	"cca2": "AT",
    	"ccn3": "040",
    	"cca3": "AUT",
    	"cioc": "AUT",
    	"independent": true,
    	"status": "officially-assigned",
    	"unMember": true,
    	"unRegionalGroup": "Western European and Others Group",
    	"currencies": {"EUR": {"name": "Euro", "symbol": "\u20ac"}},
    	"idd": {
    		"root": "+4",
    		"suffixes": ["3"]
    	},
    	"capital": ["Vienna"],
    	"altSpellings": ["AT", "Osterreich", "Oesterreich"],
    	"region": "Europe",
    	"subregion": "Western Europe",
    	"languages": {
    		"bar": "Austro-Bavarian German"
    	},
    	"translations": {
    		"cym": {"official": "Republic of Austria", "common": "Awstria"},
    		"deu": {"official": "Republik Österreich", "common": "Österreich"},
    		"fra": {"official": "République d'Autriche", "common": "Autriche"},
    		"hrv": {"official": "Republika Austrija", "common": "Austrija"},
    		"ita": {"official": "Repubblica d'Austria", "common": "Austria"},
    		"jpn": {"official": "オーストリア共和国", "common": "オーストリア"},
    		"nld": {"official": "Republiek Oostenrijk", "common": "Oostenrijk"},
    		"por": {"official": "República da Áustria", "common": "Áustria"},
    		"rus": {"official": "Австрийская Республика", "common": "Австрия"},
    		"spa": {"official": "República de Austria", "common": "Austria"}
    	},
    	"latlng": [47.33333333, 13.33333333],
    	"demonyms": {
    		"fra": {
    			"f": "Autrichienne",
    			"m": "Autrichien"
    		},
    		"spa": {
    			"f": "Austriaco",
    			"m": "Austriaca"
    		}
    	},
    	"landlocked": true,
    	"borders": ["CZE", "DEU", "HUN", "ITA", "LIE", "SVK", "SVN", "CHE"],
    	"area": 83871,
    	"callingCodes": ["+43"],
    	"flag": "\ud83c\udde6\ud83c\uddf9"
    }
  5. View CSV country data examples

    master
    The project provides country data in CSV format. The CSV structure uses dot-notation for nested fields (e.g., name.common, translations.deu.official) to represent the hierarchical data found in the JSON version.
  6. Reference the Country Data Schema

    master

    Each country entry in the dataset contains the following fields:

    • name: Object containing:
      • common: Common name in English.
      • official: Official name in English.
      • native: Object where keys are ISO 639-3 language codes and values are objects containing official and common translations.
    • tld: Country top-level domain.
    • cca2: ISO 3166-1 alpha-2 code.
    • ccn3: ISO 3166-1 numeric code.
    • cca3: ISO 3166-1 alpha-3 code.
    • cioc: International Olympic Committee code.
    • independent: Boolean indicating if the country is a sovereign state.
    • status: ISO 3166-1 assignment status.
    • unMember: UN Member status.
    • unRegionalGroup: UN Regional Group.
    • currencies: Object where keys are ISO 4217 currency codes and values are objects containing name and symbol.
    • idd: International Direct Dialing info:
      • root: Geographical code prefix (e.g., +6).
      • suffixes: List of assigned suffixes.
    • capital: List of capital city names.
    • altSpellings: List of alternative spellings.
    • region: Geographical region.
    • subregion: Geographical subregion.
    • languages: Object where keys are ISO 639-3 language codes and values are English names of the languages.
    • translations: Object where keys are ISO 639-3 language codes and values are objects containing official and common translations.
    • latlng: Array of latitude and longitude coordinates.
    • demonyms: Object where keys are ISO 639-3 language codes and values are genderized objects containing f (female) and m (male) translations.
    • landlocked: Boolean indicating if the country is landlocked.
    • borders: List of border country codes.
    • area: Land area in km².
    • flag: Emoji flag.
    • callingCodes: List of calling codes.
  7. Exclude specific fields from the output

    master
    You can generate a custom dataset by excluding specific fields using the php countries.php convert command. Use the --exclude-field flag or the shorthand -x flag. You can exclude multiple fields by repeating the flag.
  8. Configure output directory and formats

    master
    When running the conversion command, you can specify a custom output directory using --output-dir and restrict the output to specific formats (e.g., json_unescaped, csv) using the --format flag or the shorthand -f flag.