ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 05-01-2011
Nischith Kashyap's Avatar
Nischith Kashyap Nischith Kashyap is offline
Flexsim User
 
Join Date: Nov 2010
Location: Wollongong, Australia
Posts: 51
Downloads: 26
Uploads: 0
Thanks: 19
Thanked 0 Times in 0 Posts
Rep Power: 118
Nischith Kashyap is on a distinguished road
Default 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..
Attached Thumbnails
Click image for larger version
Name:	Test File csv.jpg
Views:	147
Size:	37.7 KB
ID:	1368   Click image for larger version
Name:	flexsim table.jpg
Views:	146
Size:	57.8 KB
ID:	1369  
  #2  
Old 05-03-2011
mark.gormley mark.gormley is offline
Flexsim User
 
Join Date: Oct 2008
Posts: 58
Downloads: 12
Uploads: 0
Thanks: 32
Thanked 63 Times in 29 Posts
Rep Power: 181
mark.gormley has a spectacular aura aboutmark.gormley has a spectacular aura about
Default

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  
Old 05-04-2011
Nischith Kashyap's Avatar
Nischith Kashyap Nischith Kashyap is offline
Flexsim User
 
Join Date: Nov 2010
Location: Wollongong, Australia
Posts: 51
Downloads: 26
Uploads: 0
Thanks: 19
Thanked 0 Times in 0 Posts
Rep Power: 118
Nischith Kashyap is on a distinguished road
Default

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  
Old 05-05-2011
mark.gormley mark.gormley is offline
Flexsim User
 
Join Date: Oct 2008
Posts: 58
Downloads: 12
Uploads: 0
Thanks: 32
Thanked 63 Times in 29 Posts
Rep Power: 181
mark.gormley has a spectacular aura aboutmark.gormley has a spectacular aura about
Default

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


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.