Kuopassa.net

Lisää kirjoituksia netistä.

Etsi blogista

Jos harkitset liittymistä, käytä alennuskoodia 00033583 niin saat 25€ pois palvelumaksuista. Hyödynnä alekoodi heti, sillä en tiedä kuinka kauan tuo kampanja kestää, mutta se vaikuttaa olevan voimassa ainakin 24.1.

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.
About the author

"Nordea exchange rate (.dat) parser in PHP" is rated 7 out of 10. That rating was formed of 1 vote(s). Kuopassa.net´s blog includes a total of 1222 posts including this one. If you´d like to link to this page from a blog or a forum, please use this permalink. Tag or tags: .

Tsekkaa myös minkälaisia valokuvia teen: www.pjti.fi