Search code examples
pythoncurrency

Python library to convert full currency names to their appropriate abbreviation


I have a list of currencies as:

       'United States dollar', 'European Euro', 'Indian rupee',
       'Pound sterling', 'Canadian dollar', 'Brazilian real',
       'Australian dollar', 'Polish zloty', 'Russian ruble', 'Swedish krona',
       ...
       'Macanese pataca', 'Samoan tala', 'Libyan dinar', 'Namibian dollar',
       'Cayman Islands dollar', 'Fijian dollar', 'Lesotho loti',
       'Turkmen manat', 'Somali shilling', 'Mozambican metical'

Are their any existing libraries that can help me convert these names to their proper abbreviations For example:

United States dollar -- USD
European Euro -- EUR
Indian Rupee -- INR etc

Solution

  • You can make use of this JSON data to find the abbreviations and symbols https://gist.github.com/stevekinney/8334552. Through this, you can iterate through the data and can easily find the symbol and abbreviation with their names.