added option to append CSV headers
This commit is contained in:
parent
20a4673f98
commit
c992100a38
@ -2,8 +2,11 @@
|
||||
"storage.Storage.append": "Append string data to a new or existing file.",
|
||||
"storage.Storage.appendBuffer": "Append a buffer to a new or existing file.",
|
||||
"storage.Storage.appendCSV": "Append a row of CSV data",
|
||||
"storage.Storage.appendCSVHeaders": "Append a row of CSV headers",
|
||||
"storage.Storage.appendCSVHeaders|param|filename": "the file name to append data, eg: \"data.csv\"",
|
||||
"storage.Storage.appendCSVHeaders|param|headers": "the data to append",
|
||||
"storage.Storage.appendCSV|param|data": "the data to append",
|
||||
"storage.Storage.appendCSV|param|filename": "the file name to append data, eg: \"data.txt\"",
|
||||
"storage.Storage.appendCSV|param|filename": "the file name to append data, eg: \"data.csv\"",
|
||||
"storage.Storage.appendLine": "Appends a new line of data in the file",
|
||||
"storage.Storage.appendLine|param|data": "the data to append",
|
||||
"storage.Storage.appendLine|param|filename": "the file name to append data, eg: \"data.txt\"",
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"storage.Storage.appendCSVHeaders|block": "storage %source|%filename|append CSV headers %headers",
|
||||
"storage.Storage.appendCSV|block": "storage %source|%filename|append CSV %data",
|
||||
"storage.Storage.appendLine|block": "storage %source|%filename|append line %data",
|
||||
"storage.Storage.append|block": "storage %source|%filename|append %data",
|
||||
|
@ -61,8 +61,24 @@ namespace storage {
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a row of CSV headers
|
||||
* @param filename the file name to append data, eg: "data.csv"
|
||||
* @param headers the data to append
|
||||
*/
|
||||
//% blockId=storageAppendCSVHeaders block="storage %source|%filename|append CSV headers %headers"
|
||||
appendCSVHeaders(filename: string, headers: string[]) {
|
||||
let s = ""
|
||||
for (const d of headers) {
|
||||
if (s) s += "\t"
|
||||
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.txt"
|
||||
* @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"
|
||||
|
Loading…
Reference in New Issue
Block a user