Table Schema: Currency pattern


#1

There’s been discussion about making currency a data type or if currency is a unit. I thought I’d propose a pattern to nudge the conversation along.

Some questions:

  • how do you represent currencies no longer used. I’m not sure ISO-4217 has old versions of the data that supports the standard available. (There is XLS and XML for the current standard)
  • groupChar should be an option for integer e.g. to support ¥1,000 (Issue #498)
  • How is -£1000.00 handled by bareNumber, 1000.00 or -1000.00? (comment in Issue #258)

Currency

Overview

This pattern provides a way to describe currency units associated with numeric fields in a Table Schema. The “currency” property indictates the country and currency unit. The bareNumber, groupChar and decimalChar properties can be used to help the data be interpreted as a numeric value

For example, this data…

Australian Dollars UK Pounds Euro Yen
1000.00 1,000.00 €1000,00 ¥1000

…using this Table Schema…

  "schema":{
    "fields": [
      {
        "name": "Australian Dollars",
        "type": "number",
        "currency": "AUD"
      },
      {
        "name": "UK Pounds",
        "type": "number",
        "unit": "GBP",
        "groupChar": ","
      },
      {
        "name": "Euro",
        "type": "number",
        "unit": "EUR",
        "bareNumber": "true",
        "decimalChar": ","
      },
      {
        "name": "Yen",
        "type": "integer",
        "unit": "JPY",
        "bareNumber": "true"
      }

    ]
  }

…would be interpreted as…

Australian Dollars UK Pounds Euro Yen
1000.00 1000.00 1000.00 1000

Note that the Yen does not have a minor unit, so is defined as a data type of integer. The Australian Dollar does have a minor unit (cents), so is defined as a data type of number.

Specification

A numeric field MAY have a currency property. The value of the currency property MUST be an “Alphabetic Code” from ISO-4217 that represents the country and its currency.

The data type chosen for the numeric field SHOULD reflect if the currency has a minor unit.

Implementations

None known.


Table Schema: Units pattern
#2

Oh! I just found the historic denominations, so…

Specification

A numeric field MAY have a currency property. The value of the currency property MUST be an “Alphabetic Code” that represents the country and its currency from either:

The data type chosen for the numeric field SHOULD reflect if the currency has a minor unit.


#3

Even better- I found this combined list on Datahub.io

https://datahub.io/core/currency-codes


#4

Great questions @Stephen and excellent documentation in the process.