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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

First character left in file when reading first line in text file

Solved!
Go to solution

When using the function Reading from Text File  a file  I notice that the 1st character is left in the file. I read the line correctly.

When appending a 2nd line that character is in the file.

Attached is part of the code vi.

Any ideas ?

Thank you.

 

Elik

0 Kudos
Message 1 of 6
(2,916 Views)
Solution
Accepted by topic author Elik

Can you attach an actual data file and tell us what you mean by "first character". How many characters do you have per line?

 

Can you tell us what you see in the modified file and what you expect to see.

 

Everything looks right.

  1. You read the first line and thus the file pointer is right after the first line
  2. You set the file size to end(seems useless, because it does not do anything). The file pointer is still right after the first line.
  3. You write the first line you read concatenated with a second line. This will be written at the current file pointer, i.e. after the existing line
  4. The first line is in the file twice, as expected.

 

Setting the file size to "end" on an existing file does not do anything useful. Could it be you want to set file position instead?

 

Try to set the file position to start and the new data will be written from the beginning of the file.

Message Edited by altenbach on 05-28-2009 05:41 PM
Message 2 of 6
(2,909 Views)

Hi,

The 1st line for purpose of demostration is Line 1.

After reading the file and concatenated  with Line 2 the file looks like this,

 

LLine 1

 

Line 2

 

The 1st character of Line 1 stays after read and when I write back the concatenated   strings that is the final results.

I'll try to set the file pointer to starts after reading.

Thanks.

Elik

0 Kudos
Message 3 of 6
(2,892 Views)

Hi,

Thank again. Setting to start did the trick.

 

Elik

0 Kudos
Message 4 of 6
(2,891 Views)
Then please mark Altenbach's message as the solution rather than your Thank you message.  You can unmark your message by going to the Options menu to the upper right of your message.
Message 5 of 6
(2,882 Views)
My mistake. Sorry about that.
0 Kudos
Message 6 of 6
(2,859 Views)