question

Paul G8 avatar image
0 Likes"
Paul G8 asked Jason Lightfoot commented

export global table to csv

I have a global table with the following data. Worth noting that its set up with the 'Use Bundle' option.

1653551621098.png

I'm using a script in the onRunStop event to do the export. The file is created with the correct name/location, but aside from a single comma, it's empty. What am I missing?

1653551653486.png

FlexSim 22.1.2
exporttable
1653551621098.png (14.5 KiB)
1653551653486.png (13.5 KiB)
· 3
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 G8 avatar image Paul G8 commented ·
I have been trying to post the code snippet as a code snippet rather than an image, but I kept on getting cloudflare you have been blocked message.
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Paul G8 commented ·
That should be find if you mark the text with the 'Code' tool (shown as '<>' in the format editor)
0 Likes 0 ·
Paul G8 avatar image Paul G8 Jason Lightfoot ♦ commented ·
Could've been a temporary glitch I guess - but as I'd had to write the post up about 3 times before that U thought I'd play it safe :)
0 Likes 0 ·

1 Answer

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

The subnode of GlobalTables isn't where the data is stored. I would use this instead:

forobjectlayerunder(Model.find("Tools/GlobalTables")){
    exporttable(Table(a.name),a.name+"_export.csv",1,1);
}

or just change your exporttable line to:

exporttable(Table(xTable.name),fileNameString,1,1);
· 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 G8 avatar image Paul G8 commented ·

Awesome! Rather much like the java for (Object x : setOfObect) loop I guess.


If the forobjectlayerunder command ever got removed (the manual says its deprecated), is there a way of doing it in a regular for loo

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Paul G8 commented ·
Yes - what you had looked fine too - that why I said you could just change your exporttable call to use Table(xTable.name). Hopefully it won't get removed - it's used withing flexSim's guis and other logic too so would be an effort to replace - but you never know.
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.