oy is a library for analysis of London Oyster card history statements. It performs basic statistical analysis of journeys providing average and median journey times, journey time variation etc.
It accepts Oyster history files in CSV format. They can be downloaded from TfL website: https://oyster.tfl.gov.uk/oyster/
npm install oy --save
oy exposes a single function, which accepts CSV string as input and returns summarised journey data:
var oy = require('oy');
oy(csvData, function(err, data) {
if(err) { /* handle error */ }
console.log(data);
});
Data variable in the example above is an array consisting of multiple journey objects. Here is a sample journey object:
{
"from": {
"text": "Dalston Junction [London Overground]",
"type": "overground"
},
"to": {
"text": "Shoreditch High Street [London Overground]",
"type": "overground"
},
"durations": {
"data": [19, 20, 21, 18],
"stats": {
"size": 4,
"min": 18,
"max": 21,
"mean": 19.5,
"median": 19.5,
"stdev": 1.29
}
},
"times": {
"data": [
"2013-11-14T14:24:00.000Z",
"2013-11-15T14:24:00.000Z",
"2013-11-16T14:24:00.000Z",
"2013-11-14T14:24:00.000Z"
],
"stats": {}
}
npm test