1

I want to include multiple csv files and I want to refer to the them in a loop. All my files have systematic names: file1.csv, file2.csv etc. How do I create a loop including all the files?

I am looking for something like this:

set j /1*10/
loop(j,
  $include "filej.csv")

How do I go about it?

k.dkhk
  • 481
  • 1
  • 11
  • 24

1 Answers1

1

One way to do this is with the Put Writing Facility.

set     fn      / '1.csv' * '10.csv' /;
file    output  / output.rsp /;
put     output  /;

loop(fn, 
        put '$include file' fn.tl /);

This will produce a file output.rsp with contents:

$include file1.csv
$include file2.csv
...
$include file10.csv

Then $include output.rsp in the relevant .gms file.

Berenger
  • 376
  • 2
  • 8