取消
显示结果 
搜索替代 
您的意思是: 

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 项奖励
1 条消息(共 18 条)
4,170 次查看
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 项奖励
2 条消息(共 18 条)
4,158 次查看
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 项奖励
3 条消息(共 18 条)
4,159 次查看
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
4 条消息(共 18 条)
4,160 次查看
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 项奖励
5 条消息(共 18 条)
4,153 次查看
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 项奖励
6 条消息(共 18 条)
4,145 次查看
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 项奖励
7 条消息(共 18 条)
4,141 次查看
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 项奖励
8 条消息(共 18 条)
4,136 次查看
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 项奖励
9 条消息(共 18 条)
4,135 次查看
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 项奖励
10 条消息(共 18 条)
4,068 次查看