* support for custom csv separator

* simple datalog frameowrk

* api strings

* hide setfile

* storage fixes

* log seconds, not milliseconds
This commit is contained in:
Peli de Halleux
2018-01-11 22:53:28 -08:00
committed by GitHub
parent c992100a38
commit 21195e4abf
8 changed files with 142 additions and 9 deletions

View File

@ -6,7 +6,10 @@ namespace storage {
//% fixedInstances
export class Storage {
constructor() { }
csvSeparator: string;
constructor() {
this.csvSeparator = ",";
}
protected mapFilename(filename: string) {
return filename;
@ -69,23 +72,23 @@ namespace storage {
appendCSVHeaders(filename: string, headers: string[]) {
let s = ""
for (const d of headers) {
if (s) s += "\t"
if (s) s += this.csvSeparator;
s = s + d;
}
s += "\r\n"
this.append(filename, s)
}
/**
* Append a row of CSV data
* @param filename the file name to append data, eg: "data.csv"
* @param data the data to append
*/
/**
* Append a row of CSV data
* @param filename the file name to append data, eg: "data.csv"
* @param data the data to append
*/
//% blockId=storageAppendCSV block="storage %source|%filename|append CSV %data"
appendCSV(filename: string, data: number[]) {
let s = ""
for (const d of data) {
if (s) s += "\t"
if (s) s += this.csvSeparator;
s = s + d;
}
s += "\r\n"