LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pick out empty strings from an array

Hello!
Now we have a textfile that we read from. With a while-loop we create an array with selected columns from the textfile. Sometimes this column is empty and then we get empty strings in the array to. How can we get rid off these in our array? Could anyone help us with this? Thank you.
Best regards.
0 Kudos
Message 1 of 18
(3,517 Views)
If the entire column is empty, try this: read the entire array once (saves file operations), and go over the array with a for loop, depending on the number of columns you want. For each column, use a case structure with a shift register to determine if the column is empty and if it is, don't insert it into the new array. If you want to build the array column by column from the file, do the same thing when reading the file. Here's an example.

___________________
Try to take over the world!
0 Kudos
Message 2 of 18
(3,505 Views)
If the entire column is empty, try this: read the entire array once (saves file operations), and go over the array with a for loop, depending on the number of columns you want. For each column, use a case structure with a shift register to determine if the column is empty and if it is, don't insert it into the new array. If you want to build the array column by column from the file, do the same thing when reading the file. Here's an example.

___________________
Try to take over the world!
0 Kudos
Message 3 of 18
(3,506 Views)
Hello Ex-Jobb,

instead of using an auto-indexed output-tunnel in your while loop you have to use a shift register initialized as array of strings. In each iteration you add the read string to the string array. Then you put a case fram around the "build array" and add only if the string is non-empty. That's it.

Best regards,
GerdW
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 18
(3,507 Views)
Gerd!

Are you from Sweden perhaps? 🙂 Thank you for the tip. We don´t want to use the build array-vi because it demands to much memory. We only have a stringarray directly from our while-loop. Can we follow your advise anyway? Best regards.
0 Kudos
Message 5 of 18
(3,500 Views)
Hello tst!

Thank you for your help! The thing is that there is not any empty column. We meant that there is sometimes empty rows in the column. And we don´t want these empty rows... but we will check your suggestion 🙂
0 Kudos
Message 6 of 18
(3,492 Views)
Hello,

I am sorry but the solution proposed by Gerd would be quite elegant and not that much memory consuming if you're not dealing with enormous text files...So you said you're a LabVIEW beginner but you know build array uses to much memory??? 🙂

By the way Gerd, thanks for the comments on a previous post

Regards,
Cyril Bouton
Active LabVIEW Developper
0 Kudos
Message 7 of 18
(3,488 Views)
Hello Cyril!

Yes we know that because someone told us :-). And yes we are beginners in LabVIEW 🙂 so there is no other way than using build array you think?
0 Kudos
Message 8 of 18
(3,483 Views)
hello again,

There is always another solution... If you do not want to use the build array function, you could use the delete from arrau function by detecting the indexes of the empty rows...not sure you would gain that much efficiency there...
Cyril Bouton
Active LabVIEW Developper
0 Kudos
Message 9 of 18
(3,482 Views)
Cyril and Gerd!

We are very new on LabVIEW so we think that was an unnecessary comments before from Cyril :-(... and we don´t understand what Gerd meant with the suggestion that we should change the tunnel to a shiftregister. We now have tunnel with indexing enable. Should one drag that to a build array after the while-loop or in the while-loop?
0 Kudos
Message 10 of 18
(3,415 Views)