Hello everybody,
I would like to merge the content of 2 CSV files containing time stamp and temperature value in one chart. I'm trying around for several hours now, nothing works. If I try to join the 2 data, just the second one is displayed.
Maybe anyone can please help me to get it sorted.
Please find attached the two CSV files. I had to rename them to TXT.
maxaussentemp.txt (171 Bytes)
minaussentemp.txt (174 Bytes)
[
{
"id": "c27cef39f950c56d",
"type": "inject",
"z": "8141eaf8a0322a8e",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "start",
"payload": "1",
"payloadType": "num",
"x": 150,
"y": 1600,
"wires": [
[
"21cd0b284985c978",
"47e51539fdb31b99",
"d8bf29920d97806d",
"9be8e52396fb9498"
]
]
},
{
"id": "d8bf29920d97806d",
"type": "file in",
"z": "8141eaf8a0322a8e",
"name": "min temp",
"filename": "/run/media/georg/E622951F2294F5B1/Users/Georg Schmitz/Documents/Heinenstr44/NodeRed/csv/minaussentemp.csv",
"filenameType": "str",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 360,
"y": 1540,
"wires": [
[
"ac1e46421a5763ca",
"c90d97410787348b",
"334a72c4989dfedf",
"47d255e21723d34d",
"767446906f91157d"
]
]
},
{
"id": "9be8e52396fb9498",
"type": "file in",
"z": "8141eaf8a0322a8e",
"name": "max temp",
"filename": "/run/media/georg/E622951F2294F5B1/Users/Georg Schmitz/Documents/Heinenstr44/NodeRed/csv/maxaussentemp.csv",
"filenameType": "str",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 360,
"y": 1660,
"wires": [
[
"89d1779cbcf350f7",
"3542b1609f4d13b4",
"685950d73a90dbab",
"daa7d136cc5d0593",
"b71909e88b2248c0"
]
]
},
{
"id": "47d255e21723d34d",
"type": "csv",
"z": "8141eaf8a0322a8e",
"name": "min",
"sep": ";",
"hdrin": false,
"hdrout": "",
"multi": "mult",
"ret": "\\n",
"temp": "x,y",
"skip": "0",
"strings": true,
"include_empty_strings": false,
"include_null_values": false,
"x": 590,
"y": 980,
"wires": [
[
"b4be8d4d6c4b03ac",
"833972c7aea4839a"
]
]
},
{
"id": "daa7d136cc5d0593",
"type": "csv",
"z": "8141eaf8a0322a8e",
"name": "max",
"sep": ";",
"hdrin": false,
"hdrout": "",
"multi": "mult",
"ret": "\\n",
"temp": "x,y",
"skip": "0",
"strings": true,
"include_empty_strings": false,
"include_null_values": false,
"x": 590,
"y": 1060,
"wires": [
[
"d5e774b756425363",
"f7ec47e21b73f86e"
]
]
},
{
"id": "b4be8d4d6c4b03ac",
"type": "function",
"z": "8141eaf8a0322a8e",
"name": "graph generate",
"func": "\nfunction toTimestamp(strDate){\n var datum = Date.parse(strDate);\n return datum/1000;\n }\nvar payload=msg.payload;\n\n\nvar data_out=[];\nvar a1=[];\n\nfor(let i=0;i<payload.length;i++)\n{\n \n//var Data= payload[i].Data.split(\"-\");\n//var t=Data[2]+\"/\"+Data[1]+\"/\"+Data[0];\n// timestamp=toTimestamp(t+\" \"+payload[i][\"Godzina\"]);\n\n\nvar temp1={ \"x\":( payload[i][\"x\"]), \"y\":( payload[i][\"y\"]) };\n\n\na1.push(temp1);\n\n \n \n //\n \n \n}\n\ndata_out=[a1];\nmsg.payload=[{\n\"series\": [\"min\"],\n\"data\":data_out,\n\"labels\": [\"01\"]\n}];\n\nmsg.topic = \"min\"\nmsg.parts = \"1\"\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 780,
"y": 980,
"wires": [
[
"5c21f7b931bfbd6b",
"1f5496113b60fee8"
]
]
},
{
"id": "8019ec2f1a59377b",
"type": "function",
"z": "8141eaf8a0322a8e",
"name": "",
"func": "// [{\n// \"series\": [\"A\", \"B\", \"C\"],\n// \"data\": [\n// [{ \"x\": 1504029632890, \"y\": 5 },\n// { \"x\": 1504029636001, \"y\": 4 },\n// { \"x\": 1504029638656, \"y\": 2 }\n// ],\n// [{ \"x\": 1504029633514, \"y\": 6 },\n// { \"x\": 1504029636622, \"y\": 7 },\n// { \"x\": 1504029639539, \"y\": 6 }\n// ],\n// [{ \"x\": 1504029634400, \"y\": 7 },\n// { \"x\": 1504029637959, \"y\": 7 },\n// { \"x\": 1504029640317, \"y\": 7 }\n// ]\n// ],\n// \"labels\": [\"\"]\n// }]\n\nlet data = []\nmsg.payload = msg.payload.forEach(el => {\n\n data.push({ \"x\": el[0], \"y\": el[1] })\n\n})\n\nlet chartData = [{\n series: [\"Wavelength\"],\n data: [data],\n labels: [\"\"]\n}]\n\nmsg.payload = chartData;\n\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1280,
"y": 1320,
"wires": [
[]
]
},
{
"id": "a14ba8c4.e546c8",
"type": "function",
"z": "8141eaf8a0322a8e",
"name": "",
"func": "//1. lets create a variable to hold the finished article...\nlet chartData = []; //See #1 - create an empty array\n\n//2. lets create a variable to hold the everything...\nlet element1 = {}; //create element1 as an empty object {}\n\n//3, now add the .property \"series\" to the element1 {object}\nelement1.series = []; // add a .property called series of type [array]\nelement1.series.push(\"Intensity\");\nelement1.series.push(\"Wavelength\");//add 1st array element \"A\"\n\n\n//4. now add the .property \"data\" to the element1 {object}\nelement1.data = [[],[]]; // add a .property called data of type [array]\n\n\n\n/*********** NEXT - ADDING DATA ***************************\n NORMALLY, ADDING DATA WOULD BE DYNAMIC \n PERHAPS LOOPING THROUGH AN ARRAY\n THIS EXAMPLE SHOWS ADDING HARD CODED VALUES\n************************************************************/\n//4b. now we add 3 arrays to the data [array]\n\n//4c. now add the 3 {objects} inside each of the dataElements\nconst data = msg.payload\nfor(let x = 0; x < data.length; x++){\n \n element1.data[0][x] = {x: x, y: data[x][0]}\n element1.data[1][x] = {x: x, y: data[x][1]}\n}\n\n//5. now add a labels [array] to element1\nelement1.labels = [\"\"]; // add a .property called labels of type [array]\n\n//Lastly, return the chartData as the payload \nmsg.payload = [element1];\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 815,
"y": 1320,
"wires": [
[]
],
"l": false
},
{
"id": "d5e774b756425363",
"type": "function",
"z": "8141eaf8a0322a8e",
"name": "graph generate",
"func": "\nfunction toTimestamp(strDate){\n var datum = Date.parse(strDate);\n return datum/1000;\n }\nvar payload=msg.payload;\n\n\nvar data_out=[];\nvar a1=[];\n\nfor(let i=0;i<payload.length;i++)\n{\n \n//var Data= payload[i].Data.split(\"-\");\n//var t=Data[2]+\"/\"+Data[1]+\"/\"+Data[0];\n// timestamp=toTimestamp(t+\" \"+payload[i][\"Godzina\"]);\n\n\nvar temp1={ \"x\":( payload[i][\"x\"]), \"y\":( payload[i][\"y\"]) };\n\n\na1.push(temp1);\n\n \n \n //\n \n \n}\n\ndata_out=[a1];\nmsg.payload=[{\n\"series\": [\"max\"],\n\"data\":data_out,\n\"labels\": [\"01\"]\n}];\nmsg.parts = \"2\"\nmsg.topic = \"max\"\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 780,
"y": 1060,
"wires": [
[
"5c21f7b931bfbd6b"
]
]
},
{
"id": "5c21f7b931bfbd6b",
"type": "join",
"z": "8141eaf8a0322a8e",
"name": "",
"mode": "custom",
"build": "array",
"property": "topic",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "2",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 990,
"y": 1060,
"wires": [
[
"b89792e99fa4fd73"
]
]
},
{
"id": "b89792e99fa4fd73",
"type": "ui_chart",
"z": "8141eaf8a0322a8e",
"d": true,
"name": "",
"group": "533e8032.78164",
"order": 4,
"width": 0,
"height": 0,
"label": "test",
"chartType": "line",
"legend": "true",
"xformat": "MM.DD-HH:mm",
"interpolate": "linear",
"nodata": "",
"dot": true,
"ymin": "-15",
"ymax": "40",
"removeOlder": "2",
"removeOlderPoints": "",
"removeOlderUnit": "86400",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 1150,
"y": 1060,
"wires": [
[
"1f5496113b60fee8"
]
]
},
{
"id": "1f5496113b60fee8",
"type": "debug",
"z": "8141eaf8a0322a8e",
"name": "joincsv",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1310,
"y": 980,
"wires": []
},
{
"id": "833972c7aea4839a",
"type": "change",
"z": "8141eaf8a0322a8e",
"name": "Set data",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "\t\t [\t {\t\t \"series\": [\"Small Loft\"],\t \"labels\": [\"H\"],\t \t \"data\": [\t [\t $.payload.\t {\t \t \"x\": $fromMillis(Unix_Time*1000),\t \"y\": Value\t \t }\t ]\t ]\t }\t ]\t",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 680,
"y": 1140,
"wires": [
[
"75cd55b257ed2ed3"
]
]
},
{
"id": "f7ec47e21b73f86e",
"type": "change",
"z": "8141eaf8a0322a8e",
"name": "Set data",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t\t \"series\": [\"Utility\"],\t \"labels\": [\"H\"],\t \t \"data\": [\t [\t $.payload.\t {\t \t \"x\": $fromMillis(Unix_Time*1000),\t \"y\": Value\t \t }\t ]\t ]\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 680,
"y": 1220,
"wires": [
[
"1b724ca9fc7ca2f4"
]
]
},
{
"id": "75cd55b257ed2ed3",
"type": "function",
"z": "8141eaf8a0322a8e",
"name": "chart1",
"func": "msg.topic = \"chart1\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 810,
"y": 1140,
"wires": [
[
"7ae84d62b1b72049"
]
]
},
{
"id": "1b724ca9fc7ca2f4",
"type": "function",
"z": "8141eaf8a0322a8e",
"name": "chart2",
"func": "msg.topic = \"chart2\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 810,
"y": 1220,
"wires": [
[
"7ae84d62b1b72049"
]
]
},
{
"id": "6f1fac0043955331",
"type": "debug",
"z": "8141eaf8a0322a8e",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 1270,
"y": 1220,
"wires": []
},
{
"id": "7ae84d62b1b72049",
"type": "join",
"z": "8141eaf8a0322a8e",
"name": "Join data",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "num",
"reduceFixup": "",
"x": 960,
"y": 1180,
"wires": [
[
"43eea6d746fd9cb2"
]
]
},
{
"id": "43eea6d746fd9cb2",
"type": "change",
"z": "8141eaf8a0322a8e",
"name": "Set payload",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \t \"series\":\t [\t [payload.chart1[0].series[0]],\t [payload.chart2[0].series[0]] \t ],\t \t \t \"data\":\t [\t [payload.chart1[0].data[0]],\t [payload.chart2[0].data[0]]\t ],\t \t \t \"labels\":\t [\t [payload.chart1[0].labels[0]],\t [payload.chart2[0].labels[0]] \t ]\t \t }\t]\t\t",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1110,
"y": 1180,
"wires": [
[
"6f1fac0043955331",
"f043fa72dbc83bb0"
]
]
},
{
"id": "f043fa72dbc83bb0",
"type": "ui_chart",
"z": "8141eaf8a0322a8e",
"d": true,
"name": "",
"group": "533e8032.78164",
"order": 4,
"width": 0,
"height": 0,
"label": "test",
"chartType": "line",
"legend": "true",
"xformat": "MM.DD-HH:mm",
"interpolate": "linear",
"nodata": "",
"dot": true,
"ymin": "-15",
"ymax": "40",
"removeOlder": "20",
"removeOlderPoints": "",
"removeOlderUnit": "86400",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 1270,
"y": 1120,
"wires": [
[]
]
},
{
"id": "b8ad0b81be3f7b8f",
"type": "csv",
"z": "8141eaf8a0322a8e",
"name": "temp",
"sep": ";",
"hdrin": false,
"hdrout": "",
"multi": "mult",
"ret": "\\n",
"temp": "x,y,z",
"skip": "0",
"strings": true,
"include_empty_strings": false,
"include_null_values": false,
"x": 530,
"y": 1380,
"wires": [
[
"e6d730fb7625df5b"
]
]
},
{
"id": "e6d730fb7625df5b",
"type": "json",
"z": "8141eaf8a0322a8e",
"name": "",
"property": "payload",
"action": "str",
"pretty": false,
"x": 750,
"y": 1380,
"wires": [
[
"288175e97496e778"
]
]
},
{
"id": "288175e97496e778",
"type": "ui_chart",
"z": "8141eaf8a0322a8e",
"name": "",
"group": "533e8032.78164",
"order": 4,
"width": 0,
"height": 0,
"label": "test",
"chartType": "line",
"legend": "true",
"xformat": "MM.DD-HH:mm",
"interpolate": "linear",
"nodata": "",
"dot": true,
"ymin": "-15",
"ymax": "40",
"removeOlder": "20",
"removeOlderPoints": "",
"removeOlderUnit": "86400",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 990,
"y": 1380,
"wires": [
[]
]
},
{
"id": "844b61bccb3f2628",
"type": "join",
"z": "8141eaf8a0322a8e",
"name": "",
"mode": "auto",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": "false",
"timeout": "",
"count": "",
"reduceRight": false,
"x": 350,
"y": 1200,
"wires": [
[]
]
},
{
"id": "767446906f91157d",
"type": "csv",
"z": "8141eaf8a0322a8e",
"name": "min",
"sep": ";",
"hdrin": false,
"hdrout": "",
"multi": "mult",
"ret": "\\n",
"temp": "x,y",
"skip": "0",
"strings": true,
"include_empty_strings": false,
"include_null_values": false,
"x": 510,
"y": 1540,
"wires": [
[
"eb75d0905c0f14dc"
]
]
},
{
"id": "b71909e88b2248c0",
"type": "csv",
"z": "8141eaf8a0322a8e",
"name": "max",
"sep": ";",
"hdrin": false,
"hdrout": "",
"multi": "mult",
"ret": "\\n",
"temp": "x,y",
"skip": "0",
"strings": true,
"include_empty_strings": false,
"include_null_values": false,
"x": 510,
"y": 1660,
"wires": [
[
"9e41a7260c32369d"
]
]
},
{
"id": "eb75d0905c0f14dc",
"type": "function",
"z": "8141eaf8a0322a8e",
"name": "function 5",
"func": "msg.topic = \"min\"\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 660,
"y": 1540,
"wires": [
[
"aedad6e7594725f2"
]
]
},
{
"id": "9e41a7260c32369d",
"type": "function",
"z": "8141eaf8a0322a8e",
"name": "function 6",
"func": "msg.topic = \"max\"\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 660,
"y": 1660,
"wires": [
[
"c6dee16b21c54524"
]
]
},
{
"id": "f2d92a0d6c34de54",
"type": "ui_chart",
"z": "8141eaf8a0322a8e",
"name": "",
"group": "533e8032.78164",
"order": 4,
"width": 0,
"height": 0,
"label": "",
"chartType": "line",
"legend": "true",
"xformat": "MM.DD-HH:mm",
"interpolate": "bezier",
"nodata": "",
"dot": true,
"ymin": "",
"ymax": "",
"removeOlder": "2",
"removeOlderPoints": "",
"removeOlderUnit": "86400",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 1110,
"y": 1580,
"wires": [
[]
]
},
{
"id": "aedad6e7594725f2",
"type": "function",
"z": "8141eaf8a0322a8e",
"name": "graph generate",
"func": "\nfunction toTimestamp(strDate){\n var datum = Date.parse(strDate);\n return datum/1000;\n }\nvar payload=msg.payload;\n\n\nvar data_out=[];\nvar a1=[];\n\nfor(let i=0;i<payload.length;i++)\n{\n \n//var Data= payload[i].Data.split(\"-\");\n//var t=Data[2]+\"/\"+Data[1]+\"/\"+Data[0];\n// timestamp=toTimestamp(t+\" \"+payload[i][\"Godzina\"]);\n\n\nvar temp1={ \"x\":( payload[i][\"x\"]), \"y\":( payload[i][\"y\"]) };\n\n\na1.push(temp1);\n\n \n \n //\n \n \n}\n\ndata_out=[a1];\nmsg.payload=[{\n\"series\": [\"min\"],\n\"data\":data_out,\n\"labels\": [\"01\"]\n}];\n\nmsg.topic = \"min\"\nmsg.parts = \"1\"\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 840,
"y": 1540,
"wires": [
[
"f2d92a0d6c34de54"
]
]
},
{
"id": "c6dee16b21c54524",
"type": "function",
"z": "8141eaf8a0322a8e",
"name": "graph generate",
"func": "\nfunction toTimestamp(strDate){\n var datum = Date.parse(strDate);\n return datum/1000;\n }\nvar payload=msg.payload;\n\n\nvar data_out=[];\nvar a1=[];\n\nfor(let i=0;i<payload.length;i++)\n{\n \n//var Data= payload[i].Data.split(\"-\");\n//var t=Data[2]+\"/\"+Data[1]+\"/\"+Data[0];\n// timestamp=toTimestamp(t+\" \"+payload[i][\"Godzina\"]);\n\n\nvar temp1={ \"x\":( payload[i][\"x\"]), \"y\":( payload[i][\"y\"]) };\n\n\na1.push(temp1);\n\n \n \n //\n \n \n}\n\ndata_out=[a1];\nmsg.payload=[{\n\"series\": [\"max\"],\n\"data\":data_out,\n\"labels\": [\"02\"]\n}];\nmsg.parts = \"2\"\nmsg.topic = \"max\"\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 840,
"y": 1660,
"wires": [
[
"f2d92a0d6c34de54"
]
]
},
{
"id": "533e8032.78164",
"type": "ui_group",
"name": "Bla",
"tab": "f8b4e17b9f2918c9",
"order": 1,
"disp": true,
"width": "11",
"collapse": false,
"className": ""
},
{
"id": "f8b4e17b9f2918c9",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]
Thank you very much in adanve!
Georg