LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

In read text Vi , reading extra lines

Solved!
Go to solution

I am using read text file line by line

 

if i have 22 lines means, it counting as 23 .. i m facing problem untitled.JPGhere

 

please help me

0 Kudos
Message 1 of 8
(2,665 Views)

First, Insert into Array is the wrong function to use.  You should be using Build Array.

 

You get an extra line because when you get an error that stops the while loop (and I'm guessing that is probably an End of File Error), you wind up passing an empty string from the Read function to the array building case structure.  That becomes an empty string element at the end of the array.

 

You should only build the data onto the end of the array when there is no error.

0 Kudos
Message 2 of 8
(2,657 Views)

You can completely remove the While loop, just by wiring -1 to the count terminal of Read from Text File function.

 

Read all Lines.png

 

And you can remove following While loop.

 

Read Line 1 by 1


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


Message 3 of 8
(2,650 Views)

yes , exactly, while getting empty error. it getting count of one line

 

but i couldnt get u, wat is ur suggestion..

 

kindly brief it please

 

thanks ..

 

0 Kudos
Message 4 of 8
(2,649 Views)

But i have multiple files , without while loop , how would i read all the text files 😞

 

0 Kudos
Message 5 of 8
(2,647 Views)
Solution
Accepted by topic author gowthamggk

So you need a loop (I'll prefer For loop), to read all files (1 by 1) and Read from Text File function placed in the loop, reading all the lines in each file in one go... So suppose you've 10 files to be read, For loop will execute 10 times and so will Read from Text File function.

 

Edited: added, It seems you already have a For loop (the outer most)... I was mentioning that you can remove the While loop (inner loop shown in your picture, also I had encircled it in Red)... For loop will still gonna be stay there.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


Message 6 of 8
(2,643 Views)

Why do you have a case structure with a 1 constant wired into it?

 

Get rid of the constant and wire your error wire into the selector.  The build array function would be in the "No Error" case.

 

Of course this doesn't handle your multiple file question.  Moderator provided information to help you figure that out.

 

I'm only trying to help you figure out why your current code isn't working like you expected.  I'm not going to try to read your mind and figure out everything it is you are trying to do.

Message 7 of 8
(2,631 Views)

This thread seems so familiar.  We actually told you all of this in your other thread:http://forums.ni.com/t5/LabVIEW/I-want-handle-single-array-for-multiple-files/m-p/2513678


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 8
(2,600 Views)