Importing array data from excel to global table?

Importing array data from excel to global table?

rajankur6494
Advocate Advocate
45 Views
6 Replies
Message 1 of 7

Importing array data from excel to global table?

rajankur6494
Advocate
Advocate

[ FlexSim 20.0.10 ]

Hi Team,

I am importing array data from excel as Array[2]: {Room1, Room2} but it is read as string in assigning label logic.

How can I get it back to array?

Or what is the best way to import such data since user will be interacting from excel only?

Thank you!

0 Likes
Accepted solutions (1)
46 Views
6 Replies
Replies (6)
Message 2 of 7

joerg_vogel_HsH
Mentor
Mentor
Resolve your data in excel to single values only: strings or numbers!
0 Likes
Message 3 of 7

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

If you can't do as Jorg suggest and keep single values in the cells then you can postprocess the import using the string.split() method

0 Likes
Message 4 of 7

rajankur6494
Advocate
Advocate

Hi @Jason Lightfoot@Joerg Vogel,

I have built my model logic to work for array. So, after importing data in cells, how can I convert that into array for every row in global table?

Thank you!

0 Likes
Message 5 of 7

jason_lightfootVL7B4
Autodesk
Autodesk
Table t=Table("GlobalTable1");
for (int n=t.numRows;n>0;n--){    //iterate through the rows
    string s=t[1];   // row n, column 1
    Array sArray=s.split(",");   // get the array using comma delimiter
    t.cell(n,1).value=sArray.clone();  // overwrite the table cell value
}

If you just have your values comma separated in Excel the above code will convert the column to arrays.

ConvertTableCellToArray.fsm

0 Likes
Message 6 of 7

rajankur6494
Advocate
Advocate
Hi @Jason Lightfoot ,

I couldn't open this model since I am using version 21.1.5.

Thank you!


0 Likes
Message 7 of 7

jason_lightfootVL7B4
Autodesk
Autodesk
0 Likes