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!

Looping through an input file

Status
Not open for further replies.

Knackers

Technical User
Apr 26, 2001
59
0
0
AU
Hi Guys,

I am trying to process the data in a text file. Problem is that the data is in a strange format. The data is a bunch of attributes about Dogs - but instead of having the data for each dog in the file on a single line (which would just allow you to use the StringTokeniser to break it up), it is spread accross 3 lines, in the following format:

Code:
<ID> <breed>
<temperament>
<neutered?> <age> <length of stay>
123 Kelpie
friendly, active
no 2.4 4
Each dog (therefore each 3 lines) must be processed seperately. I have been sucessful in processing this data for the first dog in the file, but I am a bit stuck on how I should loop through the rest. I was thinking that I could use a 'for' loop, but that would require knowing how many lines there are in the file - is there anyway of knowing this?

Does anyone else have any ideas on how I might so this?

Cheers
 
Why is it that as soon as you post something, you manage to work it out anyway?

I just declared a boolan eof = false,

then just used a 'while' loop, testing to see if readLine = Null to break out of the loop.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top