Hi all,
Is there any way to refer to the CSV files 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?
Created a loop including CSVs Topic is solved
Re: Created a loop including CSVs
Hi Richard
Just starting to learn how to use embededded code in Gams. Here a solution with python:
Hope this helps
Cheers
Renger
Just starting to learn how to use embededded code in Gams. Here a solution with python:
Code: Select all
$onEmbeddedCode Python:
f = open('myinclude.inc', 'w')
for i in range(10):
f.write('$include'+'" file' + str(i)+'.csv"\n')
f.close()
$offEmbeddedCode
$include myinclude.inc
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Re: Created a loop including CSVs
Hi @Renger , Thanks a lot ! It was very helpful.