I've run into a bit of confusion...
I'm working with some rather large CSV files of time series data with a bit of overlap. This is patient data so I can't share exact examples, but what I'm trying to do is combine many months of vital signs alarms but also separate each bed and alarm type into its own context variable (bed-1-SPO2, bed-1-tachycardia, bed-2-SPO2, etc.)
I've been pretty successful so far with this by splitting the input file into a stream of messages assigning topics based on the content of specific columns, and applying the following function:
if (flow.get(msg.topic) === undefined){
flow.set((msg.topic), msg.payload);
}
else {
var oldval = flow.get(msg.topic)
var newval = msg.payload
var finalval = oldval.concat(newval)
var deduped = Array.from(new Set(finalval));
msg.payload = deduped
flow.set((msg.topic), msg.payload)}
return msg;
which I'm using to check if any data of this type has already been saved and if there is any add the new data to it and remove any identical rows to eliminate overlap. From what I can tell from the context explorer, this portion seems to be working like a charm and my resulting stored variable looks to be an array of strings.
Now comes my problem: When I attempt to call back this data using a function node containing node.send({"payload":flow.get(msg.payload)});
what I expect is an object containing that same array of strings, but what I'm actually geting is an object containing an array of single element arrays with the expected string living in element 0. I feel like I have to be overlooking something simple, but my limited experience has me for a loss as to what it could be.