Javascript Location for CSV databases

Hi All

Quick question.

For a particular database I need to assign a separate field with a number based off data from a existing field.

For a another database i used the following and it seemed to work

data.extract(‘./CUSTOMER[1]/Country[1]’);
var myData = data.extract(‘./CUSTOMER[1]/Country[1]’,0);
if (myData==‘CA’)
‘1’;
else {
if (myData == ‘US’)
‘2’;
else
‘’;
}

I got the data location from the datamapper where it had a field XPath:

Now for a CSV file it doesnt seem to have a XPath:

Mode: Location

Column: (field name)

As a example, lets say the column I need to use is called State

Mode: Location

Column: State

top offset: 0

I created a new column called insert to use this

How would i change the previous script to reference this column?
Would the mode still Location then type in Post function:

Or would it be same as previous javascript.

EDIT

It seems Just typing the column name seem to have worked, but realised the issue was more for the actual script.

I presumed if there is more then 2 variables, for example VIC gets 1, NSW gets 2, QLD gets 3 then the if and else doesnt seem to work?

Not well versed in javascript

Many Thanks

Best Regards

Jason

For a CSV file you can’t use xPath, but it has a columnName and a rowOffset.

From online help:
data.extract(columnName, rowOffset)

Extracts the text value from the specified column and row.

columnName: String that represents the column name.

rowOffset: Number that represents the row index (zero-based), relative to the first row in the record. To extract the first row, specify 0 as the rowOffset.

Small clarification on MartinS’ answer: the rowOffset parameter for the data.extract() method is relative to the current position (and not to the first row of the record). So for instance, if you have a Goto step that jumps to the 10th line, issuing a data.extract(“MyField”,0) command immediately after it would extract the value on the tenth row, not on the first one.