LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating a spreadsheet

Hi,
 
I have a txt file with the following data:
 
12345   .10
98765    25
 
The rows are tab delimited. The first number in each row is an "account number" and the second number is their "balance". I have made a labview program that reads this file and takes a constance account number and compares it to the ones in the file. After it finds a match it subtracts a constant number from the balance and outputs the remaining balance..
 
I want to know if it is possible to 'update' this txt file by changing the 'balance' amount with the new balance of just one row.
 
It sounds a little confusing so if you have questions please ask and i will try to clarify.
 
Also, how would i set it up so that when it finds a match the for loop stops running. Right now if the match is the first one it still checks the second row to see if there is a match.
 
Thanks.
 
0 Kudos
Message 1 of 4
(2,639 Views)

You are doing this way too complicated. There is no loop needed.

Just extract the 1D array of account numbers, use "search 1D array" to find the row index of the desired account and subtract from the element in column 1 of that same row.

Here is one possibility.

Message Edited by altenbach on 03-04-2007 11:57 AM

Download All
0 Kudos
Message 2 of 4
(2,630 Views)

In general, you cannot simply replace a single row in an existing text file, because the number of bytes per number (and per row) is variable and thus the file size must change and all higher bytes need to be moved up or down accordingly.

Simply write the entire edited array back to the file, overwriting the original.

(If you would use a binary file format, it would be possible to overwite a certain postions in the file without problems. Another possibility would be to use a text file with fixed field lenghts)

Message Edited by altenbach on 03-04-2007 12:05 PM

0 Kudos
Message 3 of 4
(2,623 Views)
Thanks alot! This really helped me out.
0 Kudos
Message 4 of 4
(2,597 Views)