Giter VIP home page Giter VIP logo

codici-stati's Introduction

Country data

This repository contains some files with country data. They are useful to developers that have to deal with data collected and exchanged in Italy, because they contain the country codes at the end of the tax code (codice fiscale) for people born outside Italy, the one used by ISTAT and the one used by the Ministero dell'Interno.

Country data:

  • English name
  • Italian name
  • ISO3361 2 letter code
  • ISO3361 3 letter code
  • country code for the Italian tax code
  • ISTAT code
  • code used by the Ministero dell'Interno

The data is in the dist/ directory

File formats

  • PostgreSQL SQL dump format
  • MySQL SQL dump format
  • MongoDB mongoexport format
  • two JSON objects, one indexed by the tax code and the other by the 3 letter code
  • two Ruby modules that embed two Hash structures indexes as the JSON objects

The database tables contain no indexes. You must add them as required by your application.

Examples

$ irb
2.2.3 :001 > require "./dist/ruby/countries/iso3361_1_alpha_3.rb"
 => true
2.2.3 :002 > Countries::Iso3361_1_Alpha_3.get("GBR")
 => {"english_country_name"=>"United Kingdom of Great Britain and Northern Ireland",
  "iso3361_3_characters"=>"GBR", "iso3361_2_characters"=>"GB", "istat"=>219,
  "minint"=>219, "italian_country_name_1"=>"GR. BRET. - IRLANDA DEL NORD (REGNO UNITO)",
  "italian_country_code"=>"Z114", "taxcode_country_code"=>"Z114",
  "italian_country_name_2"=>"GRAN BRETAGNA E IRLANDA DEL NORD"}
2.2.3 :003 > require "./dist/ruby/countries/tax_code.rb"
 => true
2.2.3 :004 > Countries::TaxCode.get("Z102")
 => {"english_country_name"=>"Austria", "iso3361_3_characters"=>"AUT",
 "iso3361_2_characters"=>"AT", "istat"=>203, "minint"=>203,
 "italian_country_name_1"=>"AUSTRIA", "italian_country_code"=>"Z102",
 "taxcode_country_code"=>"Z102", "italian_country_name_2"=>"AUSTRIA"}

There are two italian_country_name fields because the data sources sometimes use different names for the same country. Both are included.

Data sources

The two Excel files are not included in the repository because I'm unsure about their license. If you want to run the generator script you must download them to the data directory.

Generator script

The files in the dist directory have been generated with the make-tables.rb Ruby script. It's not necessary to run it because the generated files are in the repository but in case you want to or have to (updates to the data, JSON and Ruby files with different indexes):

  • Run bundle to install the gems
  • Configure the script as explained below
  • ruby make-tables.rb

The script is likely to need some configuration to access the databases on your local machine. Furthermore, you have to create those databases first.

Look for the # CONFIGURATION comments in the file. There are three of them Each one introduces a database's section and is followed by the commands to create the database and tables or (in the case of MongoDB) the collection. Then there is a line that creates the connection to the database. You'll need to customize it. The script is currently written to get the MySQL credentials from the environment and must be run like this MYSQL_USER=user MYSQL_PASS=pass ruby make-tables.rb. It assumes that no credential are needed to connect to the PostgreSQL. Works for me but probably not for you. The connection details for mongo are in the mongo.yml file.

At the end of every database's section there is another comment with the CLI command to dump the country_codes tables/collection to the dist directory.

License

data/wikipedia.csv is subject to the license of https://en.wikipedia.org/wiki/ISO_3166-1 which at the time of writing is a Creative Commons Attribution-ShareAlike 3.0

The files in the dist directory, the Gemfile, the make-tables.rb script and this README are released into the Public Domain:

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.