1. How to import CSV or Excel files 2. How to handle timetable content functionally

1. How to import CSV or Excel files 2. How to handle timetable content functionally

kentaro_banABGLD
Advocate Advocate
951 Views
11 Replies
Message 1 of 12

1. How to import CSV or Excel files 2. How to handle timetable content functionally

kentaro_banABGLD
Advocate
Advocate

I would like to consult with you on whether the following two requirements can be implemented. Please find the detailed information below.

1. Directly importing Excel/CSV data into the model I have created an Excel file that replicates the content of the "Edit Table" in the source. I would like to convert this into a CSV file and import it directly, then use that imported data as-is within the model. I suspect that using a "Global Table" might be the approach for this, but I would like to confirm. I have attached the relevant Excel data for your reference.

2. Functionally updating timetable content via data input In the "Production Process" timetable, I have already scheduled Gantt bars representing "down states." Currently, I am inputting these manually while checking the times on the table chart. This method is already quite effective, but to make it more versatile, I want to avoid having to manually drag the Gantt bars to change the start and end times. I would like to know if there is a way to make this automatic—for example, by using labels or a specific table where I can input numbers or dates that then reflect automatically on the timetable.

I would appreciate your guidance on these matters. Thank you in advance for your help.I'm sorry for the inconvenience, but could you please provide the data as an attachment?

0 Likes
Accepted solutions (1)
952 Views
11 Replies
Replies (11)
Message 2 of 12

kentaro_banABGLD
Advocate
Advocate

I apologize for the trouble. Could you please let me know if this is achievable?

0 Likes
Message 3 of 12

FelixMoehlmann
Collaborator
Collaborator

1) You can use the Excel Import/Export tool to directly import a sheet into the source sequence table. The format has to match of course for the source to work. Also, at least for me, the data in the excel sheet must start in the first row.

Screenshot 2026-04-23 082223.png

 

2) You can switch to the table view for the time table. This table could be imported from Excel in the same way.

Screenshot 2026-04-23 083606.png

0 Likes
Message 4 of 12

kentaro_banABGLD
Advocate
Advocate

Thank you for your response.

1) Regarding point 1, I understand that the source arrival sequence data can be used as table data. However, I am unclear about the relationship between "Excel Workbook" and "Table Data." Furthermore, I do not have access to Excel and am using "Just Calc." When I select a file created in Just Calc as the "Excel Workbook" and click OK, it does not throw an error, but the simulation does not update when I change the values in that file. As an alternative, I understand that I might need to import the data after converting it to a CSV file, but I am not sure how to perform this process. Additionally, the tutorial mentions using code, but I don’t know where exactly I should be entering it. Could you please provide guidance on these points?

2) Regarding point 2, I apologize for my previous lack of clarity. I am aware that a timetable can be converted into a table, but my concern is whether those numerical values can be handled programmatically—for instance, by using labels or assigned values—so that they can be managed dynamically when simulation conditions change. If this is not possible, I fear I would have to manually re-enter every value for every new simulation scenario, which would be very labor-intensive. If there is no other way, I will accept that, but could you please let me know if there is a more efficient approach?

0 Likes
Message 5 of 12

FelixMoehlmann
Collaborator
Collaborator

1) You can import a csv file with "importtable()". Though to be able to import headers the target needs to be a global table (or a node that is formatted in the same way). From the global table you can clone the data to the source.

Table sequenceTable = Table("GlobalTable1").as(treenode);
importtable(sequenceTable.as(treenode), modeldir() + "/SequenceTable.csv", 1, 1);
sequenceTable.cloneTo(Model.find("Source1>variables/sequence"));

2) The table data is stored in the tree. You can cast the respective node as a table class variable and use the usual methods to access/alter the data. I doubt this works during a model run but you can change the table depending on parameters or other values on reset.

Table timeTable = Model.find("Tools/TimeTables/生産工程>variables/table");
timeTable[1][3] = 7200;   // Set duration of first break to 2 hours

 

0 Likes
Message 6 of 12

kentaro_banABGLD
Advocate
Advocate

Thank you for your response.

1) Regarding the CSV import: Initially, I assumed this method involved manually selecting a CSV file, similar to opening a file in software like Just Calc or Excel. However, it appears I was mistaken. Is it correct to understand that this function automatically reads the CSV file simply by placing it in the specific folder directory?

Following this, I have a question regarding the execution. I have prepared the Global Table and the CSV file, and executed the script you provided via the 'FlexScript Console.' However, nothing happened. The original CSV filename was quite long, so I renamed it to something shorter and updated the script accordingly. Is this the correct approach? I have attached a screenshot and the CSV file I am using for your reference.

2) Regarding the TimeTables location: I have navigated down the model tree and reached 'TimeTables.' However, I am unsure where exactly I should input the code you provided. Could you please guide me on where to enter this, or perhaps provide a screenshot if possible to clarify the location?I will determine whether this is effective after implementing it.

0 Likes
Message 7 of 12

FelixMoehlmann
Collaborator
Collaborator

1) Yes, the command uses a filepath to open a specific file on your PC. Is the file path you pass into the function correct (the csv is saved in the same location as the model)?

Depending on the settings of your operating system FlexSim might expect a different separator than commas. Maybe try specifying the separator in the optional parameters of the command.

The ".as(treenode)" in the first line is actually not needed. It was left in by accident from an earlier version of the script.

2) You can execute the code from anywhere (for example the script console). It gets a reference to the table node of the time table from the path in the first line.

0 Likes
Message 8 of 12

kentaro_banABGLD
Advocate
Advocate

Thank you for your response.
1)I apologize for the inconvenience. I have done some research and tried writing the code myself, but I keep getting errors. To be direct, what exactly should I write, and where should I put it?And it is written that the importtable() function is required to import from a CSV file, but what kind of code should I write, and where should I insert it?

0 Likes
Message 9 of 12

FelixMoehlmann
Collaborator
Collaborator

If the csv is saved in the same directory as the model then the code I posted a couple replies ago should work. You might of course need to adjust the code so it uses the correct names for Global Table, csv and Source.

Table sequenceTable = Table("GlobalTable1");
importtable(sequenceTable.as(treenode), modeldir() + "/SequenceTable.csv", 1, 1);
sequenceTable.cloneTo(Model.find("Source1>variables/sequence"));

 I can't tell you where to place the code because I don't know when/how often you want to import tables. If it's only one time, use the Script Console. Another useful options might be the On Set trigger of a parameter, where the parameter value could be the file name to import.

If this doesn't work then please attach an example model so I can investigate.

0 Likes
Message 10 of 12

kentaro_banABGLD
Advocate
Advocate

Hello,
Thank you for your response.
I have attached the sample model data and the CSV file. We would appreciate it if the implementation could be carried out using this data. I apologize for the inconvenience and thank you for your cooperation.

0 Likes
Message 11 of 12

FelixMoehlmann
Collaborator
Collaborator
Accepted solution

I don't see any issues with the model. Using the code I provided in the Script Console works to update the source table.

0 Likes
Message 12 of 12

kentaro_banABGLD
Advocate
Advocate

Thank you for your response. I realized I had the wrong reference for a word in the script. It was a basic mistake on my part. I apologize for the trouble.

0 Likes