Export all(!) entries of a GDX-File to Excel - Is it still possible in Studio on Linux platform? Topic is solved

questions about GAMS' tools
Post Reply
Sascha.Herrmann
User
User
Posts: 1
Joined: 2 weeks ago

Export all(!) entries of a GDX-File to Excel - Is it still possible in Studio on Linux platform?

Post by Sascha.Herrmann » 2 weeks ago

Hi,

I remember the possibility to export all(!) entries of a GDX-File into a single excel file using one right mouse click in the old GAMS-IDE.
While GAMS-Studio 1.3.5 has now descent possibility to browse GDX-Files, I can only find an export to clipboard function for a single entry of the GDX-File.

Is the export all GDX entries to an excel workbook function still available, and if not, is there any other possibility to export everything at once?
(My model has more than 130 entries, so doing the export by hand is pretty cumbersome, isn't it?)

Thanks, Bye Sascha

Lutz
User
User
Posts: 40
Joined: 4 years ago

Re: Export all(!) entries of a GDX-File to Excel - Is it still possible in Studio on Linux platform?

Post by Lutz » 2 weeks ago

Hi,

At the moment, this is not possible with Studio. However, we extended the Python packages that come with GAMS with GAMS 33, so that you could just add the following to the end of your model to do the task on all platforms:

Code: Select all

embeddedCode Python:
import pandas as pd
import gams2numpy
gams.wsWorkingDir = '.'
g2np = gams2numpy.Gams2Numpy(gams.ws.system_directory)
writer = pd.ExcelWriter('all.xlsx', engine='openpyxl')
for sym in gams.db:
   arr = g2np.gmdReadSymbolStr(gams.db, sym.name)
   pd.DataFrame(data=arr).to_excel(writer, sheet_name=sym.name)
writer.save()   
endEmbeddedCode
Hope that helps,
Lutz

Post Reply