GAMS:更改文件名以包含在循环中
GAMS: changing names of files to include in a loop
我想包含多个 csv
文件并且我想在循环中引用它们。我所有的文件都有系统名称:file1.csv, file2.csv etc
。
如何创建包含所有文件的循环?
我正在寻找这样的东西:
set j /1*10/
loop(j,
$include "filej.csv")
我该怎么做?
一种方法是使用 Put Writing Facility。
set fn / '1.csv' * '10.csv' /;
file output / output.rsp /;
put output /;
loop(fn,
put '$include file' fn.tl /);
这将生成一个文件 output.rsp
,其内容为:
$include file1.csv
$include file2.csv
...
$include file10.csv
然后 $include output.rsp
在相关 .gms
文件中。
我想包含多个 csv
文件并且我想在循环中引用它们。我所有的文件都有系统名称:file1.csv, file2.csv etc
。
如何创建包含所有文件的循环?
我正在寻找这样的东西:
set j /1*10/
loop(j,
$include "filej.csv")
我该怎么做?
一种方法是使用 Put Writing Facility。
set fn / '1.csv' * '10.csv' /;
file output / output.rsp /;
put output /;
loop(fn,
put '$include file' fn.tl /);
这将生成一个文件 output.rsp
,其内容为:
$include file1.csv
$include file2.csv
...
$include file10.csv
然后 $include output.rsp
在相关 .gms
文件中。