ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
||||
|
||||
String value changes to int value on importing ??
Hello
We are working on a .csv file named Train ID and we have attached a sample of the file below. We use the following code, to import it into Flexsim, as this file changes day after day, and we cannot manually import the file, but via code. The following is the code we have been using to get the csv file as a global table in Flexsim. createGlobalTable("TrainID",gettablenum("Traincoun t",1,1),4,1,0); treenode table2 = reftable("TrainID"); importtable(table2,"C:/path........./train_id.csv",0,0); The problem that we are facing is that a few ID's of the train are changing from string to int values as seen in the screen shot attached below. Is there a way to import the first column as a string, as the train id's in the first column starting with numbers are all converted into int values and not string values. If you could compare the two screen shots attached below, you could understand it clearly... Please help !! Thanks.. |
#2
|
|||
|
|||
Hi,
Do you need to create the TrainID global table each time you run the code? If not then I suggest you create the table once manually and then resize it using settablesize or addtablerows/cols. If you used this approach you could manually assign column 1 to always be string data. To do this right click on the column header for column 1 then select "Assign String Data". |
#3
|
||||
|
||||
The Train ID is basically a list of the the number of transporters on a particular day, and that does change for each day, so i would have to create the table Train ID everytime i run the code and not manually.
Is there a way of writing in code, that i need my first column as a string or any thing of that sort ?? |
#4
|
|||
|
|||
I am still not 100% sure why you cant have the table in the model and just resize it through code.
If you wanted to do it your way then I think you should be able to loop through the table and call nodeadddata(thenode,DATATYPE_STRING); on the first column for each row in the table before importing your data. This will set the node node to datatype string. |
Thread | Thread Starter | Forum | Replies | Last Post |
Excel File Importing | John Kim | Container Terminal (CT) Library | 0 | 08-06-2009 03:21 PM |
Problem with importing Excel data | David Chan | Q&A | 5 | 03-05-2009 01:49 AM |
Importing OpenFlight models | Kenny Macleod | Q&A | 2 | 08-27-2008 03:43 PM |
IF with a String | Gavin Douglas | Q&A | 1 | 07-14-2008 12:36 PM |
dbimporttable: importing date | Lolke Koopmans | Q&A | 7 | 02-22-2008 05:57 AM |