Fixed Width Manual Position Entry

Is there a way to manually enter the left and right positions for a fixed-width txt data file. I’m sent the positions of where a field begins and ends ahead of time, and I’m wonder if there is a way to input those position directly into the data mapper. I used the export model function to get the naming scheme in however that doesn’t seem to include the widths.

You will have to convert your Extraction Step’s mode from Location to JavaScript. You will then be able to use dynamic values in the data.extract() method.

For instance, let’s say that in your Workflow process, you know you need to extract a certain region. You could set JobInfo9 to something like this before calling the Execute Data Mapping task:

{left:1,right:20,topOffset:5,height:1};

Now in your data mapping configuration, you will need 3 things:

  • First, in the Preprocessor step, add a property named coords, set its scope to Each record, its type to Object and its default value to null.
  • Second, add an Action step whose type is set to Set property. In the options, select the coords property, set the Based on option to Javascript and put in the following code:
var obj;
if(automation.jobInfo.JobInfo9){
	obj=JSON.parse(automation.jobInfo.JobInfo9);
} else {
	obj = {left:1,right:10,topOffset:0,height:1};
}
obj;
  • Finally, in your extract step, set the Mode to JavaScript and type the following code:
data.extract(
	sourceRecord.properties.coords.left,
	sourceRecord.properties.coords.right,
	sourceRecord.properties.coords.topOffset,
	sourceRecord.properties.coords.height,
	"<br />"
);
1 Like

Awesome! Thank you for the response, i will give this a try.