question

Joe Hugan avatar image
0 Likes"
Joe Hugan asked Joe Hugan commented

Column Format Post Import

Is there a way to change the format (string versus number) of a column using the post import code? The first values in the imported Excel table are not indicative of the format. I want to force all the columns to text using the import then switch some of them to numeric after the import. I know I can do this in the interface but I want to automate it each time the file imports.

FlexSim 18.2.3
column formatpost code import
· 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.

Joe Hugan avatar image Joe Hugan commented ·

I just tried to set the columns B-F as Text in Excel and import. Column B has a mixture of numbers and text in FlexSim. I need them to be all text. The data is on the "schedule" tab.

eaglerail-data-chittagong-0009.xlsx

0 Likes 0 ·

1 Answer

·
Jordan Johnson avatar image
2 Likes"
Jordan Johnson answered Joe Hugan commented

If you import using the "Values Only" method, I think they will come in as mixed numbers and text. Then you could write post-import code like this:

Table myTable = Table("tableName");
for (int i = 1; i <= myTable.numRows; i++) {
    Variant value = myTable[i][col_index];
    if (value.type == VAR_TYPE_NUMBER) {
        myTable[i][col_index] = string.fromNum(value);
    }
}
· 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.

Joe Hugan avatar image Joe Hugan commented ·

thanks will try that. The syntax on the "if" was escaping me :)

0 Likes 0 ·

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.