Hi everyone,
a system is producing a broken CSV file that has one delimiter too much at the end of each line.
In order to remove this superfluous semicolon, I decided to run it through JXA (first time trying it with JXA...) and the script works in some way (meaning it produces no errors), but I can't get the output out of it.
I run a ForEach loop for each line in the CSV file variable "QSSemikolonfixCSV", each line is a "QSSemikolonfixCSVZeile", and the output... well, all I got so far was "true".
Where is my mistake? Here is the code:
function removeFinalSemicolon(csvLine) {
// Remove the final semicolon if it exists
if (csvLine.endsWith(";")) {
return csvLine.slice(0, -1);
}
return csvLine;
}
// Example usage
var app = Application.currentApplication()
app.includeStandardAdditions = true
var kme = Application("Keyboard Maestro Engine")
var csvLine = kme.getvariable("QSSemikolonfixCSVZeile");
var result = removeFinalSemicolon(csvLine);
kme.setvariable("QSSemikolonfixCSVZeile", { to: result});