Error 492 Symbol not in GDX Topic is solved

Problems with syntax of GAMS
Post Reply
TheBebbo
User
User
Posts: 16
Joined: 2 years ago

Error 492 Symbol not in GDX

Post by TheBebbo »

Hi! I´m trying to import data from excel to GAMS.

Sets
t "Zeit" /1*200



Parameters
x (t)
y (t)
z (t)


$onecho>gdxxrw Data-x-y-z.xlsx
set=t rng=Tabelle5!E2:E201 cdim=0 rdim=1
par=x rng=Tabelle5!A2:A201 cdim=0 rdim=1
par=y rng=Tabelle5!B2:B201 cdim=0 rdim=1
par=z rng=Tabelle5!C2:C201 cdim=0 rdim=1

$offecho
$call GDXXRW Data-x-y-z.xlsx
$GDXIN Data-x-y-z.gdx
$LOAD t, x, y, z
$gdxIn


But then error 492 "Symbol not in GDX" appears.
It just creates an empty GDX file.


I would be very thankful for any advices.
User avatar
bussieck
Moderator
Moderator
Posts: 1042
Joined: 7 years ago

Re: Error 492 Symbol not in GDX

Post by bussieck »

Hi,

Study the documentation of gdxxrw and how to use a gdxxrw option/parameteri file. You seem to have destroyed your xlsx workbook with your command sequence. What you probably want to do is:

Code: Select all

$onecho> Data-x-y-z.txt
input = Data-x-y-z.xlsx
set=t rng=Tabelle5!E2:E201 cdim=0 rdim=1
par=x rng=Tabelle5!A2:A201 cdim=0 rdim=1
par=y rng=Tabelle5!B2:B201 cdim=0 rdim=1
par=z rng=Tabelle5!C2:C201 cdim=0 rdim=1
$offecho
$call.checkErrorLevel GDXXRW @Data-x-y-z.txt
$GDXIN Data-x-y-z.gdx
$LOAD t, x, y, z
$gdxIn
Always check the return code of external program ($call.checkErrorLevel ) in case things go bad.

-Michael

PS phpBB has a nice code section, use it!
TheBebbo
User
User
Posts: 16
Joined: 2 years ago

Re: Error 492 Symbol not in GDX

Post by TheBebbo »

Thanks for your reply! I'm new in the world of GAMS so it gets sometimes a bit hard for me. I guess my problem with creating a GDX is the error "there were at least 10 duplicate entries for symbol x". Is there an option to solve this?
Thank you really much for you help.
User avatar
bussieck
Moderator
Moderator
Posts: 1042
Joined: 7 years ago

Re: Error 492 Symbol not in GDX

Post by bussieck »

No, GAMS does not allow duplicate records. If you post the spreadsheet and what you want to read into GAMS then we might be able to help better.

-Michael
TheBebbo
User
User
Posts: 16
Joined: 2 years ago

Re: Error 492 Symbol not in GDX

Post by TheBebbo »

Hi!
In the following I show you the code I used and my Excel sheet as an attachment.

Sets
t "time" /1*51/

Parameters
X(t) Price for x at time t
Y(t) Price for Y at time t
Z(t) Price for Z at time t;

$onecho>input_data2.txt

par=X rng=priceX!B2:B51 cdim=0 rdim=1
par=Y rng=priceY!B2:B51 cdim=0 rdim=1
par=Z rng=priceZ!B2:B51 cdim=0 rdim=1
$offecho
$call GDXXRW input_data2.xlsx @input_data2.txt
$GDXIN input_data2.gdx
$LOAD X,Y,Z
$gdxIn

Now it creates an empty gxx data. Before that i had the error that duplicates are not possible.

I´m very thankful for any advice!

Best Greetings
TheBebbo
Attachments
input_data3.xlsx
(570.45 KiB) Downloaded 116 times
Fred
Posts: 373
Joined: 7 years ago

Re: Error 492 Symbol not in GDX

Post by Fred »

Hi,
the index is part of the range you are reading. So start reading at A2 instead of B2

Code: Select all

par=X rng=priceX!A2:B51 cdim=0 rdim=1
par=Y rng=priceY!A2:B51 cdim=0 rdim=1
par=Z rng=priceZ!A2:B51 cdim=0 rdim=1
Also note that the excel file name doe snot fit with your example code.
I hope this helps!

Fred
TheBebbo
User
User
Posts: 16
Joined: 2 years ago

Re: Error 492 Symbol not in GDX

Post by TheBebbo »

Thanks for your reply! I only changed the name of the excel sheet to post it here. So When I tried it it fit to the code.

I changed the range to A2:B51 but it still creates only an empty GDX file.
Fred
Posts: 373
Joined: 7 years ago

Re: Error 492 Symbol not in GDX

Post by Fred »

You are right. This is because you define t as 1,2,...,51 in your code but in your data you use t1, t2, ..., t51. By default, GAMS does a filtered load meaning that zero records are loaded. The following should work.

Code: Select all

Sets
t "time" /t1*t51/

Parameters
X(t) Price for x at time t
Y(t) Price for Y at time t
Z(t) Price for Z at time t;

$onecho>input_data2.txt

par=X rng=priceX!A2:B51 cdim=0 rdim=1
par=Y rng=priceY!A2:B51 cdim=0 rdim=1
par=Z rng=priceZ!A2:B51 cdim=0 rdim=1

$offecho
$call.checkErrorLevel  GDXXRW input_data3.xlsx @input_data2.txt trace=3
$GDXIN input_data3.gdx
$LOAD X,Y,Z
$gdxIn

display X, Y, Z;
TheBebbo
User
User
Posts: 16
Joined: 2 years ago

Re: Error 492 Symbol not in GDX

Post by TheBebbo »

It works! Thank you so much! You helped me a lot :)
Post Reply