- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a formatted file containing 1000-2000 records. I would like to ALLOCATE an array for these numbers, but I don't know how many are in the file. The standard techniques I'm familiar with are either to write the number of records in the title line of the file (it gets read by Excel also) or to read records from the file with no input list and count the number that have been read when EOF is reached. These date from the '70's. Are there more intelligent/sophisticated/elegant solutions to the problem now?
Regards,
Keith
I have a formatted file containing 1000-2000 records. I would like to ALLOCATE an array for these numbers, but I don't know how many are in the file. The standard techniques I'm familiar with are either to write the number of records in the title line of the file (it gets read by Excel also) or to read records from the file with no input list and count the number that have been read when EOF is reached. These date from the '70's. Are there more intelligent/sophisticated/elegant solutions to the problem now?
Regards,
Keith
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suspect that counting lines is the only way to go. After all, the file systems used by Windows (and Linux and U*x) don't really have the concept of a 'record', so the only way to find out how many records there are in a file is to count end-of-line markers.
On other o/s, such as VMS or MVS, some files have fixed length records, so the number of records is just file size divided by record length.
On other o/s, such as VMS or MVS, some files have fixed length records, so the number of records is just file size divided by record length.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page