question

Przemyslaw Pasich avatar image
0 Likes"
Przemyslaw Pasich asked Przemyslaw Pasich commented

Buggy bundle + importtable() interaction

The issue happens when importing a .csv using importtable() into a table that is defined to be a bundle: if the first row contains an empty string, the whole column gets disregarded completely and the import ends prematurely.

The expected result:

expected-result.png

The achieved result:

actual-result.png

The issue does not occur if the table is NOT a bundle type.

I am attaching a dummy model that recreates this issue + a sample CSV:

missing_col_when_importing_CSV_to_bundle.fsm

sample_csv.txt

Right now the workaround is to modify the .csv as a text file using fileopen() and replacing all the empty values in the first row with a dummy string value (e.g. " "), but can you please fix the issue in some future release of FlexSim so that importing to a bundle table and a non-bundle one behaves consistently?

FlexSim 24.2.0
csvimporttable
· 2
5 |100000

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

Nil Ns avatar image Nil Ns commented ·

Hello,

It looks like a bug.

As a workaround, you can import without using the bundle and then change to that using a code like this:

missing-col-when-importing-csv-to-bundle.fsm

treenode selObj = Model.find("Tools/GlobalTables/Bundle_tbl");
createview(gets(guifocusclass(selObj)), nodetopath(selObj), "");
treenode view = views().find("active>Documents/Table").last.find("+/../../..");

function_s(view.find("/TableView"), "changeBundleData");
repaintview(view.find("/TableView"));

Table tbl = Table("Bundle_tbl");
string file_path = filebrowse("*.csv;*.txt", "CSV files", modeldir());
importtable(tbl, file_path, 1,0,",");


function_s(view.find("/TableView"), "changeBundleData");
repaintview(view.find("/TableView"));
0 Likes 0 ·
Przemyslaw Pasich avatar image Przemyslaw Pasich Nil Ns commented ·
Hi Nil, thanks for the workaround! Yours is a good one especially when you cannot edit the source CSV file. I'll keep it in my notes
1 Like 1 ·

0 Answers