Post Processing - creating data file issue

Afternoon,

As per topic title, im tring to create a csv file with details from the data mapper, however when i output, i get the same record outputted for every record? Probably something simple in the below code, but i cant see what the issue is - can anyone take a look and advise?

Many thanks.

var fileIn = openTextReader(data.filename);
var tmp = createTmpFile();
var fileOut = openTextWriter(“c:/test.txt”);
var line;
var SequenceNumber
var CardNumber

var i=0
while((line = fileIn.readLine())!=null){
SequenceNumber = data.records[i].SequenceNumber
CardNumber = data.records[i].HRN
fileOut.write(SequenceNumber + ‘,’ + CardNumber)
fileOut.newLine();
i=i++
}

fileIn.close();
fileOut.close();

Are you running this from the Datamapper GUI? If so, the answer is here

If not, then try this:

var records = [].slice.call(data.records);

records.forEach(function(record) {
    SequenceNumber = record.SequenceNumber;
    CardNumber = record.HRN;

    fileOut.write(SequenceNumber + ',' + CardNumber);
    fileOut.newLine();
}
fileOut.Close();

Thank you jchamer,

Managed to get it working this morning after have slept on it.