LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problems reading from 2 text file

Hello anybody...
 
I´m trying to read 2 text files using de "Read from Text File" function, but something is not working...
 
The first file ("list.txt") contain a list of strings, where which one means a valid file (ex: "c:\file1.txt"  without " ")
The first function reads the entire file ("list.txt") and the text read from the file (strings) are converted to a path (to be used by second "Read from Text File" function block)

Content of "list.txt":
c:\file1.txt
c:\file2.txt
c:\file3.txt
....
<EOF>
 
Each string is converted to a VALID absolute path (example: "c:\file1.txt" )and connected to "file" terminal  of second function. The second function should open "c:\file1.txt", but an error occurs:

"Error 1 occurred at Read from Text file in MYTEST.vi"
"LabView: an input parameter is invalid"
Of course, file1.txt, file2.txt.... are valid .txt files and de path, if entered as a constant, there is no problem.

Some suggestion?
 
I´ve tried EVERYthing, conversions, bundle, unbundle, build path functions...but didn´t work...
Thanks!
Julio Ribeiro
0 Kudos
Message 1 of 6
(3,308 Views)
Your appended path will be:
c:\c:\file.txt

You have the full path in the file you only have to convert that to a path. No path building needed!

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 2 of 6
(3,301 Views)

The first read function is set to read lines.  when you do this an array will be the output of the first read function.  Either parse a normal read function string for the file you want or search and index the string array when set to read lines.

I attached an example that will open all files in the file using a for loop.  I do not reccomend you implement this, it was meant for illustration between the different read function settings

 

Chris Co.

0 Kudos
Message 3 of 6
(3,296 Views)
Your filename ends in a nonprintable character (\n, or newline or possibly \r\n)! Set your string to display \-codes and you see what I mean.
 
One way or the other, you need to clean it up. One simple way is shown in the attached. Modify as needed.
 
SInce your line contains the entire path, basepath is redundant and must remain empty if you use "build path". Instead, just use the "string-to-path" primitive. 🙂
 
 
Message 4 of 6
(3,296 Views)
Sorry...the VI "open_file" was not the correct example... In fact the path was only c:\file1.txt, where c:\ is not appended by Build Path function...
In resume: The result path  was only c:\file1.txt.
 
Thank you!
 
Julio Ribeiro
0 Kudos
Message 5 of 6
(3,285 Views)

Thanks, dude!

You´re right! at the end of line I have /r/n...Smiley Happy I removed and now is working.

 

Thanks everybody

Julio

Julio Ribeiro
0 Kudos
Message 6 of 6
(3,284 Views)