This repository has been archived by the owner on May 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restored a needed conversion file until thje iOS scanner outputs a be…
…tter (json) format of training and test data
- Loading branch information
1 parent
a94acc2
commit 691156f
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |