GDX File export format restricted to Excel workbook format

I’m attempting to export my solution data to a CSV from the output GDX file. However, it does not seem like I have chosen any option other than Excel. There is no dropdown menu in the highlighted button either. Is this by design or is there any other way to output the data to csv or json?

Hi,

You are correct. The GDX Viewer currently supports exporting data to Excel only, but additional data formats are planned for the future. The Export functionality leverages GAMS Connect, allowing you to inspect and modify the generated code. An example might explain best how you can modify the instructions to write to CSV instead of Excel:

  1. In GAMS Studio, press F6 to open the Model Library Explorer and load the TRNSPORT model from the GAMS Model Library.
  2. Run the model with GDX creation by pressing F10.
  3. Open trnsport.gdx in the GDX Viewer and click Export to open the Export Dialog.
  4. Select the variable x for export and choose Save instead of Export from the drop-down menu.
  5. Open the generated trnsport_export.yaml file in a text editor and replace the ExcelWriter agent with CSVWriter as follows:
CSVWriter:
    file: C:\Users\User\Documents\GAMS\Studio\workspace\trnsport_export.csv
    name: x_proj_
    # unstack: True  # write attributes (level, marginal, etc.) to the header
  1. Open a command prompt and run gamsconnect trnsport_export.yaml.

This will generate a trnsport_export.csv file containing the x variable.

Note that GAMS Connect can be executed not only from a command prompt, but also within an Embedded Code Connect section as part of a GAMS model. If this option is of interest for you, the GAMSReader agent can be used to read data from GAMS directly, bypassing the need for a GDX file.

Best,
Clemens