LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert Blank Lines in Text File

Solved!
Go to solution

Hello,

 

I would like to insert a line "Data linked on: Date" followed by 7 blank lines before the original data in the text file.  In the attached VI, I am getting truncated data with just one blank.  

 

Thanks for your time and help.

 

HiNi

Download All
0 Kudos
Message 1 of 2
(2,570 Views)
Solution
Accepted by topic author hiNI

That's because you keep resetting your start point to the beginning of the file and overwriting the beginning.

 

You can't "Insert" anything into the beginning of a file.  You can only overwrite existing data or add to the end.

 

You need to create a new file, write the stuff you want to "insert" into the beginning, then read the old file and write that data to the new file.  If you want the file name to remain the same, you can delete the old file and rename the new file as the old.

 

If the file isn't that big, you could read the entire file into memory in one shot.  Set your pointer at the start, write the new data, then write the data you saved from when you first read the entire thing.  But if the file is larger than the RAM you have available, you need to use two files like I just said before.

Message 2 of 2
(2,557 Views)