question

Paul M4 avatar image
0 Likes"
Paul M4 asked tannerp commented

Import a csv file

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);

FlexSim 19.2.4
import datacsv
5 |100000

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

Steven V avatar image
0 Likes"
Steven V answered Steven V edited

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

5 |100000

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

tannerp avatar image
0 Likes"
tannerp answered tannerp commented

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
· 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.

Paul M4 avatar image Paul M4 commented ·

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 0 ·
datacrunching-1.fsm (26.1 KiB)
tannerp avatar image tannerp Paul M4 commented ·

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 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.