⚈ Kuopassa.net

Lisää kirjoituksia netistä.

Nordea exchange rate (.dat) parser in PHP

Written

Nordea bank provides fresh data for several currency exchange rates, but collecting that data automatically can be a tiresome job. The bank does however generate a .dat feed of exchange rates where each rate is matched against Euro (EUR). The list inside .dat feed includes the exotic XDR or SDR among others. I wrote a PHP tool to parse those exchange rates from .dat feed to a neat JSON array. The script is behind a paywall, and can be unlocked with PayPal.

.dat to JSON

Nordea doesn’t have documentation that could help to decypher .dat, but I managed to generate a simple JSON feed where each currency rate includes this kind of data:

{ "week":"01", "datetime":"1999-01-01 07:30:00", "version":"0001", "to":"EUR", "from":"EUR", "average":1, "sell":1, "buy":1, "mark":"+", "end":"K000000000", "active":true }

Explanations

  • week is apparently two-digit number of week.
  • datetime probably contains the last date and time when that currency was exchanged.
  • version is either 0001 or 0002.
  • to is the result currency.
  • from is the source currency, always EUR.
  • average, selland buy are floats of exchange rates.
  • mark is either + (plus), - (minus) or (space). Perhaps they’re indicators of exhange rate trend (ie. now vs. previous).
  • end contains some mysterious string with a letter and date in format YYYYMMDD.
  • active is a boolean: marks if the currency is kaput or not.

Tagged as:

About the author