LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from Text File with Read Lines Eabled

Hello All,

 

Assume I have a text File with Two Lines (Future it may be More) so i am using  Read from Text File with Read Lines Enabled, and the Number of Lines to read is exact as my Content inside the File (2 as of now), then the Read from Text File Gives me Error 4 End of Line Encountered. whether this response is valid?

 

Though it tells that it has encountered the end of line but it still gives me a false information as i am reading Line numbers as same as content in the file.

 

The Error is more Valid when i am giving the number of lines beyond the content in the file

 

If anyone has difference in opinion please comment.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 1 of 7
(3,681 Views)

That error is End Of FILE reached.  You did read to the end of the file, so it is valid.  I just clear that specific error and move on.  If in a loop, I can use the "error cleared" output to stop the loop.



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 2 of 7
(3,677 Views)

Hi Palanivel,

 

Assume I have a text File with Two Lines (Future it may be More) so i am using  Read from Text File with Read Lines Enabled, and the Number of Lines to read is exact as my Content inside the File (2 as of now), then the Read from Text File Gives me Error 4 End of Line Encountered. whether this response is valid?

When trying to recreate your problem I fail (somehow)…

- I create a text file with two lines by opening Notepad and pressing the Enter key two times, then save this text file.

- I load this text file using ReadText, set to "read lines" mode, and have it read two lines: it's working as expected WITHOUT giving an error!

- When I try to read three lines from this file I get error 4 - as expected: I only created two lines in the file…

 

So can you provide an example which shows your problem to read two lines from a file containing (atleast) two lines of text?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 7
(3,672 Views)

Hi GerdW


@GerdW wrote:

When trying to recreate your problem I fail (somehow)…

- I create a text file with two lines by opening Notepad and pressing the Enter key two times, then save this text file.

 

 

Hope you are giving Enter Key two Times which will create extra Line (3 Lines), so try to give a Single enter key between two lines.

 

I have shared the sample File which i have used.


 

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 7
(3,664 Views)

Hi Crossrulz

 

It can be a warning and should not be a error ( Error can be Provided when my input is greater than the Number of Lines in the Files),

Error can be Cleared but still it gives me false information.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 7
(3,657 Views)

Hi Palanivel,

 

your file only contains one line - and a partial line without proper EOL chars: "TEst\r\npalani"…

When you want ReadText to detect full lines you need to provide EOL chars for each line!

 

Hope you are giving Enter Key two Times which will create extra Line (3 Lines)

No, the Enter key creates EOL chars (CR+LF in Notepad) and so ends the line.

The cursor moves to the next line, but this next line is still empty

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 7
(3,655 Views)

Hi GerdW

 

Thanks for the update, Just Found  Write to Text File with Array Input Provides Enter Key at the end of file.

 

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 7 of 7
(3,647 Views)