From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
12-01-2010 05:45 AM
Hi,
I want to replace some texts in a text file for a selected set of lines.
For eg:
if my text file contains the following data:- numbers within braces are line numbers..rest is the actual data.
(1) aaaaa
(2) bbbbb
(3) bbbbb
(4) ccccc
(5) ddddd
(6) eeeee
(7) ggggg
(8) hhhhh
(9) hhhhh
(10) hhhhh
i want to replace "hhhhh" by "ccccc" choosing a set of lines, between (5-9), so it becomes
(5) ddddd
(6) eeeee
(7) ggggg
(8) ccccc
(9) ccccc
after replacing the data, it has to be written back to the file in the same position..
changed file output..
(1) aaaaa
(2) bbbbb
(3) bbbbb
(4) ccccc
(5) ddddd
(6) eeeee
(7) ggggg
(8) ccccc
(9) ccccc
(10) hhhhh
Can this be done in labview ? any examples?
Kindly help.
12-01-2010 06:14 AM
You can try something like this:
/Y
12-01-2010 06:24 AM
hi Yamaeda,
Thanks for your reply.
But I wanted to read a file which is of huge size 40 or 50 MB (2 lakh lines - data recorded for a single day) and the operation is repeated many times within a short span of time, which in this case is difficult to achieve.
12-01-2010 06:52 AM
I assume you have atleast 2000 Mb of memory, so it should work. 😉
Else you'll have to change it slightly to use Set File position to only read and write the specific lines.
/Y
12-01-2010 07:01 AM
The Set File Position or Get File Position work with bytes offset but how to get this in terms of lines ?
Is there a way to get to a specific line in a file ?
12-01-2010 07:07 AM
@Arvinth wrote:
The Set File Position or Get File Position work with bytes offset but how to get this in terms of lines ?
Is there a way to get to a specific line in a file ?
Read line X amount of times? I dont think there's any other way. Then you might as well copy the file line by line to another file and perform the work on the selected lines, or simply do it at once like i suggested. I think it's the absolutely fastest. 🙂
/Y
12-01-2010 07:27 AM
See if either of these address your needs.
12-01-2010 12:45 PM
hi Jim,
Is the Read lines from file.vi is part of LabView 8.6.1 ? Can you tell me where it is placed in the functions palette?
Regards,
Arvinth
12-02-2010 08:39 AM
Fast and easy are not synonymous in this particular case. Fast will also depend on how much memory you are willing to eat. The fastest method I know, given your comments above, is to do the following.
You can replace steps 2-4 with simply reading the entire file from disk, but it will be a LOT slower (50MBytes should not take more than about 5 seconds to get from disk, and half that on a modern disk). Similarly, you can simply write the entire string to disk all at once, but it will be a LOT slower.
You can trade memory for speed by reading a 65,000 byte chunk, replacing, and rewriting it. Be careful with partial line reads if you do this. This will be slower because the disk will need to keep rewinding to the start of the 65,000 byte chunks on write. 65,000 bytes is the optimum chunk size for streaming to and from disk on Windows systems (NTFS and FAT32). Note that it is a broad optimum, so a bit more or less is fine if that lines up with a line boundary.
Let us know if you need more help.
12-02-2010 11:00 AM