detail table from external file or JSON field

Hi everyone,
I’m trying for the first time to bring detail records from a second CSV file into a detail table.
So far, I’ve managed to load them into a JSON field using the following script:

(function () {
  var path = ‘*\\Loan_Details.csv’;
  var r = openTextReader(path, 'Windows-1253’);
  if (!r) return '[]’;

  var mainCRS = String(record.fields['CRS'] || '').trim();
  var out = [];
  var line;

  while ((line = r.readLine()) != null) {
    if (!line) continue;
    var p = line.split('~’);
    if (p.length < 11) continue;

    var CRS = String(p[0]).replace(/^\uFEFF/, '').trim();
    if (CRS !== mainCRS) continue;

    out.push({
      CRS: CRS,
      ArDaneiou:         String(p[1]).trim(),
      ArSymvasis:        String(p[2]).trim(),
      EidosDaneiou:      String(p[3]).trim(),
      IdiotitaParalipti: String(p[4]).trim(),
      KodikosPliromis:   String(p[5]).trim(),
      Kefalaio:          String(p[6]).trim(),
      Tokoi:             String(p[7]).trim(),
      Exoda:             String(p[8]).trim(),
      SynoloOfeilis:     String(p[9]).trim(),
      EidosEpistolis:    String(p[10]).trim()
    });
  }

  r.close();
  return JSON.stringify(out);
})();

How can I turn this JSON field into a proper detail table inside the DataMapper?
Although I assume there must be an easier or more direct way to achieve this that I’m missing.

Thanks in advance for any guidance!
Akis

Quick update: I figured it out, no need to jump in — thanks though!

Would be great if you’d share your solution for others that might need it.

Of course, there you go:

A repeater after the DetailsJSON field, a repeat with type Until no more elements with maximum iterations record.fields["DetailsJSON"].length; and no Goto step required.

Action script inside the repeat, before the extractor:

var i = steps.currentLoopCounter -1;
var a = record.fields["DetailsJSON"] || [];
var d = (i >= 0 && i < a.length) ? a[i] : {};

and after that an extractor step with simple field scripts d.CRS || “”;

all the best
A.