CSV Input Using SQL2GMS

Problems with syntax of GAMS
Jarenka
User
User
Posts: 23
Joined: 3 months ago

Re: CSV Input Using SQL2GMS

Post by Jarenka » 1 week ago

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 2 times

User avatar
Renger
Posts: 187
Joined: 2 years ago

Re: CSV Input Using SQL2GMS

Post by Renger » 1 week ago

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

Post Reply