Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
restored a needed conversion file until thje iOS scanner outputs a be…
Browse files Browse the repository at this point in the history
…tter (json) format of training and test data
  • Loading branch information
GeroHerkenrath committed May 19, 2015
1 parent a94acc2 commit 691156f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions convert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/local/bin/node

'use strict';

var fs = require('fs');
var csv = require('fast-csv');
var minimist = require('minimist');

var args = minimist(process.argv.splice(2));
if (args._.length < 2) {
console.log('Usage: convert [input.csv] [output.csv]');
process.exit(-1);
}

var inFile = args._[0];
var outFile = args._[1];

var out = fs.createWriteStream(outFile);

var count = 0;
var ts;
var outRow;

function read(row) {
if (!outRow || ts !== row.Datestamp) {
ts = row.Datestamp;
if (outRow) out.write((count++ > 0 ? '\n' : '') + outRow.join(','));
outRow = [parseInt(row[' SVM-Zone (for training)'], 10)];
}
outRow.push(row[' beaconID'].trim() + ':' + parseInt(row[' RSSI'], 10));
}

function end() {
if (outRow) out.write('\n' + outRow.join(','));
}

csv
.fromPath(inFile, { headers: true })
.on('data', read)
.on('end', end);

0 comments on commit 691156f

Please sign in to comment.