LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting a number of lines from a .txt file

Hi all,
A simple question for the masters of Labview. The data file that im playing with and getting some help graphing, has lines of text at the beginning that will be of nuisance value when it comes to entering the data into a database. What is the easiest way to get rid of these. I am fairly certain that there will be 16 lines every time (including 2 blank). I was thinking of stripping the string at the start of the data and then overwriting this on the old file, but dont know how to do it. Can anyone give me a hand
Thanks
0 Kudos
Message 1 of 4
(4,674 Views)
I have attached an example. The basic premise is using the file position and rewriting the file. Rewriting the file is usually something to be avoided. I would suggest writing the new file to another directory or filename.
Stu
Stu
0 Kudos
Message 2 of 4
(4,674 Views)
Basically there are many ways to do this. If you know how many lines you want to remove, then i would scan for the 'end of line' characters (\n in '\' Codes Display), until you have reached the number of lines you want to delete, and then using the 'Match pattern' VI you can return the last portion of the string.

I have included an example of this method for you (in LV 6.0).

In the example i have also shown how you can convert the data into a spreadsheet string and saved it as such. But you could merely 'Write characters to file' using the same path, and making sure a new file is created.

I hope this helps you..

Kim
Download All
0 Kudos
Message 3 of 4
(4,674 Views)
Thanks guys, they are both very good examples and i will incorporate them into my main vi. Kim, any luck with the graphing by any chance
0 Kudos
Message 4 of 4
(4,674 Views)