简体   繁体   中英

Read 2D indexes and tuple from Execl sheet

I have tried to define Useduration as the 3D array but I did not know how to define the tuple elements. I have received an error" float of 2 dimensions not supported for sheet". is there a way to read it from excel?

`   {string} sources=...;

 range time=1..Time; 

tuple useduration {
 float frequency;
 float Averageduration;
 }
useduration Useduration[time][sources]=...;


dat.file


sources=7;
Time=2;
Useduration= [
          [<7.2,0.67>,<0.6,5>,<7.2,0.67>,<2,3>,<0.28,1>,<0.31,1>,<0.4,1>],
          [<7.2,0.67>,<0.6,5>,<7.2,0.67>,<2,3>,<0.28,1>,<0.31,1>,<0.4,1>]]`

What you could do is read 2 2D arrays and then build the tuple array:

.mod

int Time=...;
int nbsources=...;

{int} sources=asSet(1..nbsources);

 range time=1..Time; 

tuple useduration {
 float frequency;
 float Averageduration;
 }
//useduration Useduration[time][sources]=...;

float fr[time][sources]=...;
float Av[time][sources]=...;

useduration Useduration[t in time][s in sources]=<fr[t][s],Av[t][s]>;

execute
{
  writeln(Useduration);
}

.dat

nbsources=7;
Time=2;
//Useduration= [
//          [<7.2,0.67>,<0.6,5>,<7.2,0.67>,<2,3>,<0.28,1>,<0.31,1>,<0.4,1>],
//          [<7.2,0.67>,<0.6,5>,<7.2,0.67>,<2,3>,<0.28,1>,<0.31,1>,<0.4,1>]];
//          
fr= [
          [7.2,0.6,7.2,2,0.28,0.31,0.4],
          [7.2,0.6,7.2,2,0.28,0.31,0.4]];
          
Av= [
          [0.67,5,0.67,3,1,1,1],
          [0.67,5,0.67,3,1,1,1]]; 

The best way is to go through a tuple set. You have an example in this Technote:

https://www.ibm.com/support/pages/node/125333

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM