i'd like to create a HTML page using the data coming from csv. Some data come to "header", some should go as a table data.
I manged to visualize a complete csv using the tabliefy and template node. But can't a way to parse first a csv and then use a JSON object I get to create a table using a template node.
csv is like this:
`
Data | Modello | Cod. Risultato | Descrizione risultato | Peaks | Thickness | Att | Gain | CatNo | CenterPeacks | Result | SpotID | TestID |
---|---|---|---|---|---|---|---|---|---|---|---|---|
18/12/2018 09:01 | M161 | 0 | Buono | 2 | 3,39 | 3,25 | 38 | WP0806 Q+ | 0 | 1 | 12061 | 7799 |
18/12/2018 09:01 | M161 | 0 | Buono | 2 | 3,33 | 2,52 | 35 | WP0807 Q+ | 0 | 1 | 12062 | 7799 |
18/12/2018 09:01 | M161 | 0 | Buono | 2 | 3,28 | 4 | 35 | WP0808 Q+ | 0 | 1 | 12063 | 7799 |
`
and i need to get the Data and Modello to the header, I used the flow variable to get them from csv. After that i create a JSON object for the rest of the field i need. But can't find a way how to put these data into html template.
here is my flow:
[{"id":"7c2582a1.e3912c","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"6722c10c.732b48","type":"inject","z":"7c2582a1.e3912c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":120,"wires":[["db01ad75.187108"]]},{"id":"db01ad75.187108","type":"file in","z":"7c2582a1.e3912c","name":"","filename":"/home/ros_test/ADDSRL-PC_T1_07-10-2019.csv","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":440,"y":120,"wires":[["f8e61f6d.6b99f"]]},{"id":"f8e61f6d.6b99f","type":"csv","z":"7c2582a1.e3912c","name":"","sep":"\\t","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":730,"y":120,"wires":[["d5bcd946.d1ae2"]]},{"id":"d5bcd946.d1ae2","type":"function","z":"7c2582a1.e3912c","name":"","func":"var data = msg.payload;\nvar jsonObj = {};\nflow.set('date',data[0].Data);\nflow.set('modello',data[0].Modello);\nfor (let index = 0; index < 5; index++) {\n jsonObj.CodRes = data[index][\"Cod. Risultato\"];\n jsonObj.Peaks = data[index].Peaks;\n jsonObj.DesrRes = data[index][\"Descrizione risultato\"];\n jsonObj.thickness = data[index].Thickness;\n jsonObj.att = data[index].Att;\n jsonObj.gain = data[index].Gain;\n jsonObj.catNo = data[index].CatNo;\n jsonObj.centPeak = data[index].CenterPeacks;\n jsonObj.result = data[index].Result;\n jsonObj.spotID = data[index].SpotID;\n jsonObj.testID = data[index].TestID;\n console.log(\"element = \" + JSON.stringify(jsonObj))\n \n}\nmsg.payload = jsonObj;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":880,"y":120,"wires":[["cfb273d7.f1fe88"]]},{"id":"cfb273d7.f1fe88","type":"template","z":"7c2582a1.e3912c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>TEST</title>\n <style>\n body {\n font-family: Arial, Helvetica, sans-serif;\n }\n table, tr {\n border:1px solid black;\n}\n\n </style>\n</head>\n<body>\n <h1>Welding Quality data</h1>\n\n<table style=\"width:100%\">\n \n <tr>\n <td>Operatore: </td>\n <td> Primary Account</td>\n <td>Modello: </td>\n <td>{{flow.\"modello\"}} </td>\n <td>Disegno: </td>\n <td> </td>\n <td>Provati: </td>\n <td>60/60</td> \n </tr>\n \n \n \n <tr>\n <td>Data: </td>\n <td> {{flow.\"date\"}} </td>\n \n </tr>\n </table>\n \n \n </body>\n</html>\n<table style=\"width:100%\">\n <tr>\n <td {{{msg.payload}}}</td>\n </tr>\n </table> ","output":"str","x":1060,"y":120,"wires":[["dae4e870.dc5e3"]]},{"id":"dae4e870.dc5e3","type":"ui_template","z":"7c2582a1.e3912c","group":"8b5cde76.edd58","name":"template table","order":1,"width":"12","height":"18","format":"\n<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":1260,"y":120,"wires":[[]]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"30bf4544.04a522","order":1,"disp":true,"width":"12","collapse":false},{"id":"30bf4544.04a522","type":"ui_tab","name":"Home1","icon":"dashboard","disabled":false,"hidden":false}]
Processing: ADDSRL-PC_T1_07-10-2019 - Copy.csv...
ADDSRL-PC_T1_07-10-2019.txt (944 Bytes)