carxr.gms : Test Connect agent RawExcelReader

Description

This test ensures the correctness of the Connect agent RawExcelReader.

Contributor: Michael Bussieck, March 2022


Small Model of Type : GAMS


Category : GAMS Test library


Main file : carxr.gms

$title 'Test Connect agent RawExcelReader' (CARXR,SEQ=893)

$ontext
This test ensures the correctness of the Connect agent RawExcelReader.

Contributor: Michael Bussieck, March 2022
$offtext


* On the major platforms (Windows, Linux, Mac), GMSPYTHONLIB gets automatically set 
* to use the internal Python installation in sysdir/GMSPython.
$if not setEnv GMSPYTHONLIB $abort.noError Embedded code Python not ready to be used
$log --- Using Python library %sysEnv.GMSPYTHONLIB%

$onechoV > t.gms
Set s(*) Workbook sheets / '%S%1' Sheet1, '%S%2' Sheet2 /;
Set w(*) Workbook sheets by name / 'Sheet1', 'Sheet2' /;
Set ws(*,*) Workbook map / '%S%1'.'Sheet1', '%S%2'.'Sheet2' /;
Set c(*) Columns / %C%1*%C%3 /;
Set r(*) Rows / %R%1*%R%11 /;

$if not set MERGEF $set MERGEF ""
$if not set MERGES $set MERGES ""
$onUndf
Parameter vf(*,*,*) Cells with numerical value /
%S%1.%R%1 .%C%1 1, 
%S%1.%R%1 .%C%2 1, 
%S%1.%R%1%MERGEF%.%C%3 1, 
%S%1.%R%2 .%C%2 2, 
%S%1.%R%3 .%C%1 39448, 
%S%1.%R%3 .%C%2 3, 
%S%1.%R%4 .%C%1 +Inf, 
%S%1.%R%4 .%C%2 4, 
%S%1.%R%5 .%C%1 -Inf, 
%S%1.%R%5 .%C%2 5, 
%S%1.%R%6 .%C%1 NA, 
%S%1.%R%6 .%C%2 6, 
%S%1.%R%7 .%C%1 NA, 
%S%1.%R%7 .%C%2 7, 
%S%1.%R%8 .%C%1 Eps, 
%S%1.%R%8 .%C%2 8, 
%S%1.%R%9 .%C%1 Eps, 
%S%1.%R%9 .%C%2 9, 
%S%1.%R%10.%C%1 Undf, 
%S%1.%R%10.%C%2 10, 
%S%1.%R%11.%C%1 39448, 
%S%1.%R%11.%C%2 11 /;
$offUndf

Set vs(*,*,*) Cells with explanatory text /
%S%1. %R%4.%C%1 inf, 
%S%1. %R%5.%C%1 -inf, 
%S%1. %R%6.%C%1 na, 
%S%1. %R%7.%C%1 nan, 
%S%1. %R%8.%C%1 eps, 
%S%1. %R%9.%C%1 Eps, 
%S%1.%R%10.%C%1 undef, 
%S%2. %R%1.%C%1 short, 
%S%2. %R%2.%C%1 a23456789012345678901234567890123456789012345678901234567890123, 
%S%2. %R%3.%C%1 a234567890123456789012345678901234567890123456789012345678901234, 
%S%2. %R%4.%C%1 a234567890123456789012345678901234567890123456789012345678901~1, 
%S%2. %R%5.%C%1 a2345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234
%S%2. %R%6%MERGES%.%C%1 merge/;

Set %vu%(*,*,*,*) Cells with potential GAMS label /
%S%1.%R%1.%C%1.'True' True, 
%S%1.%R%1.%C%2.'1' 1, 
%S%1.%R%1%MERGEF%.%C%3.'1' 1, 
%S%1.%R%2.%C%1.'False' False, 
%S%1.%R%2.%C%2.'2' 2, 
%S%1.%R%3.%C%1.'2008-01-01 00:00:00' '2008-01-01 00:00:00', 
%S%1.%R%3.%C%2.'3' 3, 
%S%1.%R%4.%C%1.'inf' inf, 
%S%1.%R%4.%C%2.'4' 4, 
%S%1.%R%5.%C%1.'-inf' -inf, 
%S%1.%R%5.%C%2.'5' 5, 
%S%1.%R%6.%C%1.'na' na, 
%S%1.%R%6.%C%2.'6' 6, 
%S%1.%R%7.%C%1.'nan' nan, 
%S%1.%R%7.%C%2.'7' 7, 
%S%1.%R%8.%C%1.'eps' eps, 
%S%1.%R%8.%C%2.'8' 8, 
%S%1.%R%9.%C%1.'eps' Eps, 
%S%1.%R%9.%C%2.'9' 9, 
%S%1.%R%10.%C%1.'undef' undef, 
%S%1.%R%10.%C%2.'10' 10, 
%S%1.%R%11.%C%1.'39448' 39448, 
%S%1.%R%11.%C%2.'11' 11, 
%S%2.%R%1.%C%1.'short' short, 
%S%2.%R%2.%C%1.'a23456789012345678901234567890123456789012345678901234567890123' a23456789012345678901234567890123456789012345678901234567890123, 
%S%2.%R%3.%C%1.'a234567890123456789012345678901234567890123456789012345678901~1' a234567890123456789012345678901234567890123456789012345678901234, 
%S%2.%R%4.%C%1.'a234567890123456789012345678901234567890123456789012345678901~2' a234567890123456789012345678901234567890123456789012345678901~1, 
%S%2.%R%5.%C%1.'a234567890123456789012345678901234567890123456789012345678901~3' a2345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234
%S%2.%R%6%MERGES%.%C%1.'merge' merge /; 
$offecho
$call.checkErrorLevel gams t.gms lo=%gams.lo% gdx refnomerge.gdx --vu=vu --S=S --R=R --C=C
$call.checkErrorLevel gams t.gms lo=%gams.lo% gdx refmerge.gdx --vu=vu --S=S --R=R --C=C --MERGEF="*R11" --MERGES="*R10"
$onEmbeddedCode Connect:
- RawExcelReader:
    file: carxr.xlsx
- GDXWriter:
    file: ctxrxoutnomerge.gdx
    writeAll: True
$offEmbeddedCode 
$onEmbeddedCode Connect:
- RawExcelReader:
    file: carxr.xlsx
    mergedCells: True
- GDXWriter:
    file: ctxrxoutmerge.gdx
    writeAll: True
$offEmbeddedCode 

$call.checkErrorLevel gdxdiff refnomerge.gdx ctxrxoutnomerge.gdx > %system.NullFile%
$call.checkErrorLevel gdxdiff refmerge.gdx ctxrxoutmerge.gdx > %system.NullFile%

$call.checkErrorLevel gams t.gms lo=%gams.lo% gdx refnomerge.gdx --vu=vux --S=sxx --R=rxx --C=cxx
$call.checkErrorLevel gams t.gms lo=%gams.lo% gdx refmerge.gdx --vu=vux --S=sxx --R=rxx --C=cxx --MERGEF="*rxx11" --MERGES="*rxx10"
$onEmbeddedCode Connect:
- RawExcelReader:
    file: carxr.xlsx
    sheetLabel: sxx
    rowLabel: rxx
    columnLabel: cxx
    vuName: vux
- GDXWriter:
    file: ctxrxoutnomerge.gdx
    writeAll: True
$offEmbeddedCode 
$onEmbeddedCode Connect:
- RawExcelReader:
    file: carxr.xlsx
    mergedCells: True
    sheetLabel: sxx
    rowLabel: rxx
    columnLabel: cxx
    vuName: vux
- GDXWriter:
    file: ctxrxoutmerge.gdx
    writeAll: True
$offEmbeddedCode 

$call.checkErrorLevel gdxdiff refnomerge.gdx ctxrxoutnomerge.gdx > %system.NullFile%
$call.checkErrorLevel gdxdiff refmerge.gdx ctxrxoutmerge.gdx > %system.NullFile%