question

Ankur A3 avatar image
0 Likes"
Ankur A3 asked Jason Lightfoot commented

Importing array data from excel to global table?

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!

FlexSim 20.0.10
arrayexcelimport
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Joerg Vogel avatar image Joerg Vogel commented ·
Resolve your data in excel to single values only: strings or numbers!
0 Likes 0 ·

1 Answer

·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot commented

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

· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Ankur A3 avatar image Ankur A3 commented ·

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 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Ankur A3 commented ·
Table t=Table("GlobalTable1");
for (int n=t.numRows;n>0;n--){    //iterate through the rows
    string s=t[n][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 0 ·
Ankur A3 avatar image Ankur A3 Jason Lightfoot ♦ commented ·
Hi @Jason Lightfoot ,

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

Thank you!


0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.