How to read a string of Tagnames from a csv file

Hello all
Can you please help me on how I can read the string of the id as in the table below?

I want to find a way to make the function node read the string for the id for example

E01 to read as E01_UA,

E02 to read as E02_UA,

E03 to read as E03_UA,

E04 to read as E04_UA,

E05 to read as E07_UA, and so on.

The line of code in bold from the function node is where I think I need to modify:

\

msg.payload = msg.payload.replace(/(-?\d+\.\d+E[-+]\d+)/g,
function(v) { return Number(v) });

payload=msg.payload;
var n=payload.search("E");
msg.n=n;
var sub=payload.slice(n);
//msg.sub=sub.replace(/(\r\n|\n|\r)/gm, "M");
sub=sub.split("\n");
msg.payload=[];

var l=(sub.length/1);

for (var i=0;i<l-1;i++)
{
var out={};
var all={};
var a=sub[i].split(",")
var b=sub[i].split(",")
out["rv"]=a[1];
out["d"]=a[2];
out["sd"]=a[3];
out["V"]=a[4];
out["W"]=a[5];
out["F"]=a[6];
out["P"]=a[7];
 **out["id"]="E0"+(i+1);**
out["timestamp"]=Date.now();
msg.payload.push(out);
flow.set("all",msg.payload);

\

Here is the screen for the table node I am using

This is how the data from the file look like before it is update in the table dashboard

E01_UA, 0.2092123763E+002, 0.0000000000E+000, 0.1143758876E+001, 0.0000000000E+000, 0.1880263256E+002, 0.2303984271E+002, 0.0000000000E+000
E02_UA, 0.8806830641E+002, 0.0000000000E+000, 0.3886178257E+001, 0.0000000000E+000, 0.8416309878E+002, 0.9197351404E+002, 0.0000000000E+000
E03_UA, 0.1264110741E+003, 0.0000000000E+000, 0.2370249419E+002, 0.0000000000E+000, 0.1167665724E+003, 0.1360555758E+003, 0.0000000000E+000
E04_UA, 0.2338329058E+003, 0.0000000000E+000, 0.1804836659E+003, 0.0000000000E+000, 0.2072194224E+003, 0.2604463891E+003, 0.0000000000E+000
E07_UA, 0.2236577017E+002, 0.0000000000E+000, 0.2438269836E+002, 0.0000000000E+000, 0.1258386038E+002, 0.3214767995E+002, 0.0000000000E+000
E08_UA, 0.1505696738E+002, 0.0000000000E+000, 0.1429688819E+001, 0.0000000000E+000, 0.1268830300E+002, 0.1742563177E+002, 0.0000000000E+000
E09_UA, 0.3175935211E+002, 0.0000000000E+000, 0.8312104765E+001, 0.0000000000E+000, 0.2604800870E+002, 0.3747069552E+002, 0.0000000000E+000
E10_UA, 0.1283908179E+002, 0.0000000000E+000, 0.1715776294E+001, 0.0000000000E+000, 0.1024422674E+002, 0.1543393683E+002, 0.0000000000E+000
E11_UA, 0.2488148155E+003, 0.0000000000E+000, 0.7234985292E+003, 0.0000000000E+000, 0.1955302294E+003, 0.3020994016E+003, 0.0000000000E+000
E12_UA, 0.7311456750E+002, 0.0000000000E+000, 0.1492298679E+002, 0.0000000000E+000, 0.6546193871E+002, 0.8076719630E+002, 0.0000000000E+000
E13_UA, 0.1185333744E+003, 0.0000000000E+000, 0.1852562362E+003, 0.0000000000E+000, 0.9157031373E+002, 0.1454964350E+003, 0.0000000000E+000
E14_UA, -0.1029447393E+002, 0.0000000000E+000, 0.7710681912E+001, 0.0000000000E+000, -0.1579531584E+002, -0.4793632020E+001, 0.0000000000E+000
E15_UA, 0.2675784682E+003, 0.0000000000E+000, 0.3086805796E+003, 0.0000000000E+000, 0.2327738059E+003, 0.3023831305E+003, 0.0000000000E+000
E35_UA, 0.1758112170E+003, 0.0000000000E+000, 0.6057200934E+002, 0.0000000000E+000, 0.1603935464E+003, 0.1912288875E+003, 0.0000000000E+000
E36_UA, 0.2615723276E+002, 0.0000000000E+000, 0.1366443169E+004, 0.0000000000E+000, -0.4707100064E+002, 0.9938546617E+002, 0.0000000000E+000
E37_UA, 0.8135408388E+002, 0.0000000000E+000, 0.3468968698E+002, 0.0000000000E+000, 0.6968644549E+002, 0.9302172227E+002, 0.0000000000E+000
E38A_UA, -0.6093073380E+002, 0.0000000000E+000, 0.1324842048E+003, 0.0000000000E+000, -0.8373230750E+002, -0.3812916010E+002, 0.0000000000E+000
E38B_UA, 0.1015839676E+003, 0.0000000000E+000, 0.7474829542E+002, 0.0000000000E+000, 0.8445688405E+002, 0.1187110512E+003, 0.0000000000E+000
E39_UA, 0.2334203450E+002, 0.0000000000E+000, 0.1570619948E+002, 0.0000000000E+000, 0.1549115476E+002, 0.3119291424E+002, 0.0000000000E+000
E40_UA, 0.1512040735E+003, 0.0000000000E+000, 0.4130469851E+003, 0.0000000000E+000, 0.1109432644E+003, 0.1914648826E+003, 0.0000000000E+000
E41_UA, 0.2162529837E+002, 0.0000000000E+000, 0.4425810755E+002, 0.0000000000E+000, 0.8446397539E+001, 0.3480419921E+002, 0.0000000000E+000

I have manage to get the tag name with

out["id"]=a[0];

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.