I have a text file with multiple rows and columns and I have to read this data. If I am using filereadline(), I am getting text for particular row with concatenated texts from all columns. How to get the column data seperately?
I have a text file with multiple rows and columns and I have to read this data. If I am using filereadline(), I am getting text for particular row with concatenated texts from all columns. How to get the column data seperately?
IF you have rows and columns you should probably import that data into an Excel format, then FlexSim can import that data as a table. Plain text files do not distinguish between rows and columns, so neither will FlexSim's file reading commands.
I suppose, if you need to have it as a text file, perhaps you could use some character or something delineate between column in the text lines. So that when you read the file line, you can add logic that will parse out data based on that delineating character. Using string commands such as stringsearch to find those delineating characters and break that string up.
That seems like it could be very complicated though, so again, if you need to read data like a table, I'd recommend importing that data as an excel spreadsheet, or storing it in a database that can be connected to.
If you are reading a text file, perhaps in a comma separated value (.csv) format, then you should familiarize yourself with the stringtoken() command.
That is probably how you'll parse the line of text you get from filereadline().
If your data file is in JSON format, you should check out this post.
6 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved