Page 2 of 2

Re: CSV Input Using SQL2GMS

Posted: Mon Oct 08, 2018 9:15 am
by Jarenka
I am already working with including *.txt file (or *.dat file) into GAMS.

My code is the following:

Code: Select all

set Ik /Ik01, Ik02, Ik03/
    R /R01 * R08/
    Vt /Vt01,Vt02/;

$if %system.filesys% == UNIX $abort.no error 'The model cannot run on a non-Windows platform';

$onecho >  fixedtextcmd.txt
C=DRIVER={Microsoft Text Driver {*.txt}}; DBQ=C:\Users\is\Documents\gamsdir\projdir\Data;
Q=select Ik,Vt,R,var1 from vand.txt
O=fixed.inc
$offecho
$call sql2gms @fixedtextcmd.txt > %system.nullfile%

parameter p1(Ik,R,Vt) /
$include fixed.inc
/;
display p1;
And I am trying to figure out what is wrong here. I know there are other possibilities like csv file or xls file, but I would like this to be working with txt file !

Please help me.
And if you have another solution or example how to include *.txt file (or *.dat file) into GAMS it would be very helpful.

Best
Irena

My vand.txt file is attached.

Re: CSV Input Using SQL2GMS

Posted: Mon Oct 08, 2018 1:33 pm
by Renger
It looks like you forgot the *.csv and used the wrong parenthesis:

Code: Select all

set Ik /Ik01, Ik02, Ik03/
    R /R01 * R08/
    Vt /Vt01,Vt02/;


$set txtfile vand.txt   

$onecho >  fixedtextcmd.txt
C=DRIVER={Microsoft Text Driver (*.txt; *.csv)};DBQ=D:\Inbox\cge\;
Q=select Ik,Vt,R,var1 from vand.txt
O=fixed.inc
$offecho
$call sql2gms @fixedtextcmd.txt > %system.nullfile%
Cheers
Renger