LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Replace some texts in a text file for selected set of lines

Just found out the proposed solution doesn't work with line number with double digit. I'll see what I can do ;-(

0 Kudos
Message 11 of 28
(2,056 Views)

OK, not elegant and there must be something simpler but it work. I saved it in version 8.6

0 Kudos
Message 12 of 28
(2,045 Views)

Hi Arvinth,

 

For whatever reason, NI has depricated the read lines from file VI.  It should be located in  C:\Program Files\National Instruments\LabVIEW8.61\vi.lib\utility\file.llb

 

Jim

LV 2020
0 Kudos
Message 13 of 28
(2,026 Views)

Thankyou all for the reply.

 

As the text file size may vary we have to make the initialization dynamic and the array size(no. of lines) may vary from file to file.

 

I will work on the solutions suggested and get back.

 

What is the maximum size of text data that a string can handle ?

 

 

0 Kudos
Message 14 of 28
(2,024 Views)


This function was deprecated because it is no longer needed.  Read lines is an option on the Read Text File primitive (albeit somewhat hidden - right click to primitive to find it).

0 Kudos
Message 15 of 28
(2,015 Views)

 

 

The help file for the "Read from Text File" function says:

If you wire –1 to count and the size of the file you want to read is too large to be represented by a 32-bit integer, LabVIEW returns an error.

 

So the maximum number of character or lines (if you right click the function and check read lines) is I32 max value = 2147483647.

 

If your files are bigger than that you should modify your acquisition code to generate smaller files.

 

Ben64

0 Kudos
Message 16 of 28
(2,009 Views)

As I mentioned earlier, you can also modify your code to change the text so it works in chunks instead of all at once.  This will allow you to work with files of any size.  However, if you have a file that big, I would urge you to convert it to some form of binary, if you can.  Text files over a few hundred kilobytes get very unwieldy and difficult to manage.

0 Kudos
Message 17 of 28
(1,995 Views)

@DFGray wrote:


This function was deprecated because it is no longer needed.  Read lines is an option on the Read Text File primitive (albeit somewhat hidden - right click to primitive to find it).


How do you tell Read Text File WHICH lines to read?

Jim

LV 2020
0 Kudos
Message 18 of 28
(1,987 Views)

The primitive will read from the current position.  If you wish to read the fourth line, you need to call it four times with a count of one, or once with a count of four and toss the other lines.  I would only recommend this particular mode if you are not parsing a file line by line from the beginning and speed is not an issue. It is far more efficient to read chunks of the file and search for lines in the string chunk itself in most circumstances.

 

Attached is a VI with a small seek at the beginning to demonstrate the behavior.

0 Kudos
Message 19 of 28
(1,977 Views)

File position is set in bytes.  If you read a chunk of say 60 lines, how do you know how many bytes in to start your read for your second chunk?  That is what I like about read lines from file.  It gives you the byte count as an output.

Jim

LV 2020
0 Kudos
Message 20 of 28
(1,964 Views)