CSV Input Using SQL2GMS

Problems with syntax of GAMS
Post Reply
barsssk
User
User
Posts: 5
Joined: 4 months ago

CSV Input Using SQL2GMS

Post by barsssk » 4 months ago

Hello everyone. I have used SQL2GMS tool to import data from SQL, Oracle or XLS. Now I need to import csv with this tool because row limit of xls is not enough. Here is a simple example from my code to import xls:

Code: Select all

$onecho > %commandfile1%
c=DRIVER=Microsoft Excel Driver (*.xls);dbq=%filename%StoreDistances.xls;
Q1=select SOURCE,TARGET,DISTANCE from [Sheet1$]
a1=Distance
X=KoliOptDistances.gdx
$offecho
$call =sql2gms @%commandfile1%
I modified this code for csv according to sql2gms documetation https://www.gams.com/latest/docs/T_SQL2GMS.html.

Code: Select all

$onecho > %commandfile1%
c=Driver={Microsoft Text Driver (*.txt; *.csv)};dbq=%filename%PerformanceGamsSourceConstraints.csv;
Q1=select disticnt PRODUCTCODE from [PerformanceGamsSourceConstraints$]
s1=product
X=GamsSource.gdx
$offecho
$call =sql2gms @%commandfile1%
The code above gives the error: "Error: [Microsoft][ODBC Text Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides".
I have this version of GAMS for the licanse purposes. So I cannot update the gams.
DXIO.DLL version:GDX Library Jul 4, 2012 23.9.5 WIN 36376.36401 VS8 x86/MS Windows
ADO version: 6.3

Also note that, I only want to import the data with sql syntax, not to import it as table or one parameter in a single csv by using csv2gms tool.

Thanks in advance.

barsssk
User
User
Posts: 5
Joined: 4 months ago

Re: CSV Input Using SQL2GMS

Post by barsssk » 4 months ago

I found the solution :) For those having the same problem, here it is:

Code: Select all

$onecho > %commandfile1%
c=Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=E:MyPath\MyData\;
Q1=select distinct PRODUCTCODE from [PerformanceGamsSourceConstraints.csv]
s1=product
X=GamsTest.gdx

$offecho
$call =sql2gms @%commandfile1%

Post Reply