Data exchange from excel to gams (on macOS)

questions about GAMS' tools
Joy
User
User
Posts: 5
Joined: 10 months ago

Re: Data exchange from excel to gams (on macOS)

Post by Joy »

Hello I have been trying for awhile using the instructions given from excel to gams on a MacBook.
examples of codes below:

$onEmbeddedCode Connect:
- ExcelReader:
file: test.xlsx
symbols:

- name: elastc
range: sheet5!A1
rowDimension: 1
columnDimension: 1



- name: Elastva
range: sheet!A1
columnDimension: 0

- name: Elastx
range: acelastx!A1
columnDimension: 0

- name: ELASTY
range: sheet1!A1
rowDimension: 1
columnDimension: 1

- name: Elastmu
range: friscelast!A1
rowDimension: 1
columnDimension: 1



- GAMSWriter:
writeAll: True
$offEmbeddedCode



$onEmbeddedCode Connect:
- ExcelReader:
file: test.xlsx
symbols:
- name: Elastnw
range: sheet2!A1
rowDimension: 2
columnDimension: 0
- GAMSWriter:
writeAll: True
$offEmbeddedCode


$onEmbeddedCode Connect:
- ExcelReader:
file: test.xlsx
symbols:
- name: agg
range: sheet4!A1
rowDimension: 1
columnDimension: 1
- GAMSWriter:
writeAll: True
$offEmbeddedCode


the code seem to be correct but I am unable to see the parameters/set when I tried to display. I am seeing them but there is nothing in displayed.

Thanks for you help!!!
Attachments
Test.xlsx
(17.61 KiB) Downloaded 79 times
Joy
User
User
Posts: 5
Joined: 10 months ago

Data exchange from excel to gams (on macOS)

Post by Joy »

Hello I have been trying for awhile using the instructions given from excel to gams on a MacBook.
examples of codes below:

$onEmbeddedCode Connect:
- ExcelReader:
file: test.xlsx
symbols:

- name: elastc
range: sheet5!A1
rowDimension: 1
columnDimension: 1



- name: Elastva
range: sheet!A1
columnDimension: 0

- name: Elastx
range: acelastx!A1
columnDimension: 0

- name: ELASTY
range: sheet1!A1
rowDimension: 1
columnDimension: 1

- name: Elastmu
range: friscelast!A1
rowDimension: 1
columnDimension: 1



- GAMSWriter:
writeAll: True
$offEmbeddedCode



$onEmbeddedCode Connect:
- ExcelReader:
file: test.xlsx
symbols:
- name: Elastnw
range: sheet2!A1
rowDimension: 2
columnDimension: 0
- GAMSWriter:
writeAll: True
$offEmbeddedCode


$onEmbeddedCode Connect:
- ExcelReader:
file: test.xlsx
symbols:
- name: agg
range: sheet4!A1
rowDimension: 1
columnDimension: 1
- GAMSWriter:
writeAll: True
$offEmbeddedCode


the code seem to be correct but I am unable to see the parameters/set when I tried to display. I am seeing them but there is nothing in displayed.

Thanks for you help!!!
Test.xlsx
(17.61 KiB) Downloaded 74 times
Hello
I am new to GAMS and I am trying to import an excel workbook in GAMS on a MacBook. can I get some help please. I have been using Pandas Reader.
stg1_data.xlsx
User avatar
Clemens
Posts: 67
Joined: 7 years ago

Re: Data exchange from excel to gams (on macOS)

Post by Clemens »

Hi,

Your Connect code fails since the symbols Elastva, Elastx, and Elastmu want to read from the worksheets sheet, acelastx, and friscelast which do not exist in the attached Excel file. If I remove those entries from the Connect instructions, I can see data for the other symbols - e.g. elastc. The parameter agg is still empty which is due to the actual data in sheet4 which does not really contain anything suited for a two dimensional parameter. Here is my code that reads the four possible parameters:

Code: Select all

parameter elastc(*,*);
parameter ELASTY(*,*);
parameter Elastnw(*,*);
parameter agg(*,*);

$onEmbeddedCode Connect:
- ExcelReader:
    file: test.xlsx
    symbols:
      - name: elastc
        range: sheet5!A1
        rowDimension: 1
        columnDimension: 1
      - name: ELASTY
        range: sheet1!A1
        rowDimension: 1
        columnDimension: 1
- GAMSWriter:
    writeAll: True
$offEmbeddedCode


$onEmbeddedCode Connect:
- ExcelReader:
    file: test.xlsx
    symbols:
      - name: Elastnw
        range: sheet2!A1
        rowDimension: 2
        columnDimension: 0
- GAMSWriter:
    writeAll: True
$offEmbeddedCode


$onEmbeddedCode Connect:
- ExcelReader:
    file: test.xlsx
    symbols:
      - name: agg
        range: sheet4!A1
        rowDimension: 1
        columnDimension: 1
- GAMSWriter:
    writeAll: True
$offEmbeddedCode

display elastc, ELASTY, Elastnw, agg
Also for Elastnw you might want to adjust the range to sheet2!A2, but the ExcelReader will drop the first row for you automatically anyways.

Best,
Clemens
Joy
User
User
Posts: 5
Joined: 10 months ago

Re: Data exchange from excel to gams (on macOS)

Post by Joy »

I thank you so much. this really helped
Hello
I am new to GAMS and I am trying to import an excel workbook in GAMS on a MacBook. can I get some help please. I have been using Pandas Reader.
stg1_data.xlsx
Post Reply