I have a Satellite 2 line Kepler list, which is in a strict format and includes white spaces, which cannot be removed as they form the correct sequence for reading.
However the satellite name can have the white spaces removed.
I have my list for each sat like this
"SAUDISAT 1C (SO-50)
1 27607U 02058C 25275.89343148 .00004387 00000+0 54779-3 0 9994
2 27607 64.5534 204.4946 0067520 310.0132 49.5059 14.82017782226316"
Which I have now formatted to this
array[3]
0: object
col1: "SAUDISAT 1C (SO-50) whitespaces here to remove "
1: object
col1: "1 27607U 02058C 25275.89343148 .00004387 00000+0 54779-3 0 9994"
2: object
col1: "2 27607 64.5534 204.4946 0067520 310.0132 49.5059 14.82017782226316"
Note: This editor removes the multiple white spaces everywhere
I want to remove the spaces from the end of the Satellite name as it is easier to select in a switch node so I did this, which looks reasonable to me, but the output I get is triplicated, even though it does what I want.
function trim(sat) {
let trimsat = sat.trim();
msg.payload.sat = trimsat;
}
for (var i = 0; i < (msg.payload).length; i++) {
var sat = msg.payload[0].col1;
trim(sat);
var newMsg = {};
newMsg.payload = {
sat: msg.payload.sat,
line1: msg.payload[1].col1,
line2: msg.payload[2].col1,
}
node.send(newMsg);
}
return null;
result 3 times
sat: "SAUDISAT 1C (SO-50)"
line1: "1 27607U 02058C 25275.89343148 .00004387 00000+0 54779-3 0 9994"
line2: "2 27607 64.5534 204.4946 0067520 310.0132 49.5059 14.82017782226316"
How do I get this to work but just once per entry