CSV Input Using SQL2GMS

Problems with syntax of GAMS
Jarenka
User
User
Posts: 64
Joined: 5 years ago

Re: CSV Input Using SQL2GMS

Post 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.
Attachments
vand.txt
(14.1 KiB) Downloaded 206 times
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: CSV Input Using SQL2GMS

Post 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
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply