Page 1 of 1

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

Posted: Wed Nov 18, 2020 11:50 am
by Sascha.Herrmann
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

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

Posted: Thu Nov 19, 2020 3:44 pm
by Lutz
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

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

Posted: Thu Mar 04, 2021 10:09 am
by Sascha.Herrmann
This works very well. Thanks a lot, Lutz.