Here is some code for a custom mapping that will convert your fixed width file to a CSV.
A few notes:
- * Modify the header in the message = qie.createCSVMessage() line to suit your needs
- * The code assumes whitespace in the fixed width file to separate the data elements
- * Make sure your fixed width file uses newline termination (i.e. each row ends in a \n character)
// Start with a new CSV message
message = qie.createCSVMessage('Header1,Header2,Header3', true, '"', ',', 'UTF-8', true);
// Loop through each row of the source fixed width message
for (var i = 0; i < source.getCount('/'); i++) {
// Save the current row to a variable
var fxWdth = source.getNode('/[' + i + ']') + '';
// Convert to a CSV - this assumes spaces/whitespace as the
// separator between data elements (\s+ below)
var csv = fxWdth.replace(/\s+/g, ',');
csv = csv.split(',');
// Loop through the newly created CSV row
for (var x = 0; x < csv.length; x++) {
// Add the row to the CSV message
message.setNode((x+1) + '[' + (i+1) + ']', csv[x]);
}
}