Import a csv file

Import a csv file

paul_m4
Not applicable
45 Views
4 Replies
Message 1 of 5

Import a csv file

paul_m4
Not applicable

[ FlexSim 19.2.4 ]

I tried 'importtable()', but I can't get it to work.

/**Custom Code*/ treenode link = node("..>objectfocus+", c); importtable(Table(TB_Log),"U:/pmd/PerformanceAnalysis/Prep Output/Test.csv",1,1);

0 Likes
Accepted solutions (1)
46 Views
4 Replies
Replies (4)
Message 2 of 5

tanner_p
Not applicable

Hi @Paul M4,

I think the table value needs to be a string. Everything else looks fine to me.

Table(TB_Log) //Not a string
Table("TB_Log") //This should work
0 Likes
Message 3 of 5

paul_m4
Not applicable

Hi @tanner.p,

Thanks for the response.

Defining TB_Log as string returns a incomprehensible error (for me). I think because I defined TB_Log as a global variable of type Tree Node which refers to a global table.

I tried changing Tree Node to String, but that resulted in another error.

I found tostring, but that doesn't seem to work either.

Any suggestions in this context? I included the model as well.

datacrunching-1.fsm

Coincidentally, I placed a breakpoint in the code hoping to get some more insight. While stepping over the importtable line, FlexSim just crashed all together. Any idea what that's about?

Regards,

Paul

0 Likes
Message 4 of 5

steven_v
Not applicable
Accepted solution

Hello Paul,

Looking at the model you try to a create global variable to point to a table. This is a faster way of working but in this case not needed. You could just point to the string name of the table directly Table("HstMachineErrors").

Or if you want the other option to work there are 2 small mistakes:

  1. TB_Log should be a treenode
  2. TB_log should point to the data node of the table thus in this case "MODEL:/Tools/GlobalTables/HstMachineErrors>variables/data"

If you fix this you can use Table(TB_Log) as table handler

Greetings,

Steven

0 Likes
Message 5 of 5

tanner_p
Not applicable

I didn't realize that you were using TB_Log as a Global Variable that was pointing to the table. In this case, you'll need to do as Steven suggested and point specifically to the data node of the table. If you don't want to go that route, you can simply place the table name as a string in the code and have that work. I've updated your model to reflect the latter option.

datacrunching-updated.fsm

0 Likes