Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

merging records within a file?

Status
Not open for further replies.
May 3, 2001
1
0
0
US
I am writing a fortran program at tlu. This program requires to read a file with multiple records. The record has two fields - an amount and account field. I have to find a way for the computer to read a record and determine if the next record is not the same record. If it finds to be the same record, then I need to merge the two records and add the account numbers together. I want to transfer the merged account numbers and amounts together to a temp file. I'm not sure what syntax to use. Can you pleassse assist me in this manner?
 
This program requires to read a file with multiple records.

field1=0
field2=0
field1_old=0
field2_old=0

open(12,file='tempfile.dat',status='old')
100 read(12,*,end=101) field1, field2
if(field1 .eq. field1_old) field1_old=field1_old+field1
goto 100
101 continue
close(12)


This is the basic sytax that you will need. Will have to apply logic that your problem asks for.

The record has two fields - an amount and account field. I have to find a way for the computer to read a record and determine if the next record is not the same record. If it finds to be the same record, then I need to merge the two records and add the account numbers together. I want to transfer the merged account numbers and amounts together to a temp file. I'm not sure what syntax to use. Can you pleassse assist me in this manner?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top