LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to sort text file into array and back to string

Hi,
 
I had a VI that was saving CAN messages based in their ID into 4 different files.
The VI was too complex to operate with my PDA so I had to use a VI that would dump all the messages in one single text file.
Now I am trying to create a VI that will open that file, read it, read each line and perform the sorting based on the ID.
I am having difficulties because if I open the file it is read as line of strings and I cannot find the right VI that will look one line at a time.
I tried to convert it to an array using pick a line, byte to array but it is not working.
My idea was to get the text file into a 1D array and then use a for loop with indexing to do the sorting.
Is there a way to look at each line consecutely?
 
Thanks a lot,
 
Fede
0 Kudos
Message 1 of 4
(3,865 Views)
This is the text file in question
0 Kudos
Message 2 of 4
(3,860 Views)

There are many ways to do this. Sorry, I am not familiar with these types of CAN messages, so I am assuming that the ID is the first three digit number after the time.

If the ID is always 3 digits starting at offset 17, you could do something like in the attached quick demo (only sorts 100 and 101, add more cases as needed). In a real program, you might want to open the four output files, the append to the correct one depending in the ID at each iteration.

Message 3 of 4
(3,857 Views)
Thanks for the help.
I did not think about scan for tokens.
It works really well.
 
I am going to add 3 more cases and the saving structure
0 Kudos
Message 4 of 4
(3,842 Views)