Skip to content

Instantly share code, notes, and snippets.

@nikolaybotev
Created March 25, 2023 03:05
Show Gist options
  • Save nikolaybotev/083d0c38f5588b7ae7793ffed6633e34 to your computer and use it in GitHub Desktop.
Save nikolaybotev/083d0c38f5588b7ae7793ffed6633e34 to your computer and use it in GitHub Desktop.
Convert XE currency rates JSON to CSV
let c1 = require('./currency-rates-2.json')
console.log('Date,', c1.from, 'to', c1.to)
let c1b = c1.batchList[0]
let ts = c1b.startTime
for (let i = 1; i < c1b.rates.length; i += 1) {
let actualrate = c1b.rates[i] - c1b.rates[0]
console.log(new Date(ts).toLocaleDateString() + ', ' + actualrate)
ts += c1b.interval
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment