LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to determine the lines in a file?

I will work on this tomorrow night.

I will modify the all VI.

Thanks so far guys.

You are geniuses.

0 Kudos
Message 11 of 24
(1,507 Views)
Yeah, this has become another one of those "let's see how many different ways we can skin this cat". As you can see, there's often many paths to the same solution, and if you're a mystic you'd say "it's not the destination that matters, it's the journey." Umm.. yeah...
0 Kudos
Message 12 of 24
(1,502 Views)
I was looking at your VI and I see that in this way I will not be dealing with shift registers and that will not overload the memory when I am reading 120000 lines files.
 
After you use array to cluster you have 11 outputs and I think I should then substitute the parsing and manipulation to each of the 11 outputs. For example, if I want to convert to hex element 7 out of the cluster just use the regular VI to convert an hex string to a decimal value and then from there use the same code as before.
Does this make sense?
 
Also, is there a way to concatenate the output out of the cluster so that output 3 and 4 are concatenated? I am original VI I am using string subset. Here is not possible becuase I no longer have a line string with all the information but 11 different outputs.
 
I will try tonight but your approach is the one that makes more sense to me.
 
Thanks again
0 Kudos
Message 13 of 24
(1,487 Views)
Yes, for those two values that you're converting to Kelvin you could simply take the element and use the "Hexadecimal String to Number" function to parse the hex string.

You can actually simplify the VI even more by using a single "Scan From String" instead of the individual "Hexadecimal String to Number" functions by taking advantage of the fact that inside the loop we have a tab-delimited string. See attached VI for what I mean. In this case each line is being parsed out for the individual elements and then combined into the packages you want for the indvidual files. Note: I did not verify which element was going where since I got kind of lost with all the String Subset functions, so you may need to move a few wires to get the right element in the order you were trying to get them in the first place. Still, it's a heck of a lot cleaner than the original.
Message 14 of 24
(1,481 Views)
i
0 Kudos
Message 15 of 24
(1,469 Views)
i have used your idea and now it works much better and i obtain the same result.
I have another question about another VI.
I used the same tecnique to open the text file and now graph those values that I have converted.
The question that I have is that even if i only have 3 columns in my text file when i do array to cluster the unbundle function find 8 outputs and not 3.
do you know why?
 
thanks
Download All
0 Kudos
Message 16 of 24
(1,466 Views)
That is because the default size of the "Array to Cluster" function is 8 elements. To change the size you need to right-click on that function and select "Cluster Size..." and enter the size you want.

Note that you can use the "Scan From String" technique with this VI also.

Message Edited by smercurio_fc on 02-24-2006 08:45 AM

0 Kudos
Message 17 of 24
(1,460 Views)
In I put 3 it will not read the other 2 values.
just the first one.
When i run the vi the command that converts to array somehow sends 8 to the cluster command.
 
0 Kudos
Message 18 of 24
(1,451 Views)
OK, I looked at your text file and the reason why this happens is because in this file you have both spaces and tabs separating the columns. The file that you had provided earlier had either spaces or a single tab separating columns, not both. For example, there's three characters separating columns 1 and 2: a space, a tab, and another space. So, inside the loop when converting the multiple spaces to tabs you'll get three tabs to separate columns 1 and 2, which throws off your columns. If you use the "Scan From String" function you would not be affected by this, so you really should use that. (Got the hint yet? Smiley Wink)

The other thing to watch for is that the initial split at the new line may create an additional array element which is an empty string if you have a blank line at the end of the file. Your sample file contained a blank line so there was an extra element in the array that's fed to the loop. I modified your VI showing you how to use the "Scan From String" function to get the values from each row as well as some code that will eliminate the last entry being blank.

Message Edited by smercurio_fc on 02-24-2006 11:14 AM

0 Kudos
Message 19 of 24
(1,448 Views)
smercurio_fc
 
A few comments and suggestions for your code:
  1. According to the first poster, the file might contain 120000 lines, so the array of strings will be quite big. The way you conditionally strip the last element, causes a second copy of the array to be created in memory (Check with the buffer allocation tool!) and this could lead to serious performance issues. You should use a case structure instead of a "select" node. (In one case, you would strip the last element, in the other, you wire the array across unchanged).
  2. I am not sure why you would use "split array" instead of a simple "array subset". You're no using the second output anyway.
  3. There is no reason to convert an array to a cluster, then unbundle two elements. This is overly complicated and inflexible.The "index array" node does all at once and can be resized to get as many elements as you want.
🙂
Message 20 of 24
(1,436 Views)