Michael Stein, 

You are right. Thank very much for pointing to the mistake.

I was trying to read file using "with open as".  This way I was expecting to 
pull single record at every iteration of loop. 
With your suggestion, I opened entire file in memory and read each record based 
on record length in RDW. Now I can read each record as expected.

Once again thank you to all member for taking time to read my query and 
responding. Its good learning.

Thank you,
Prashant Joshi

-----Original Message-----
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of 
Michael Stein
Sent: Tuesday, May 16, 2023 11:56 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: [EXTERNAL] Re: VBS file read in windows - end of record issue

On Tue, May 16, 2023 at 04:14:07AM +0000, Prashant Joshi wrote:
>> Did you specify binary mode on the python open call? --

> Yes. And I can read the data.

How are you reading the data.  Assuming an open like:

        myfile = open("filename", "rb")

You need to either read it all into memory:

        alldata = myfile.read()
        
or read specific lengths which is messier as you need to read specific lengths, 
first 4 bytes for the RDW and then the length of the record in the RDW-4 (as 
you already read the RDW).

The 4 byte RDW includes the length of the record in the first 2 bytes 
(bigendian order) and the spanning bits in the last 2 bytes.

Either way you need to walk your way through the binary data, any code looking 
for CR or NL or space isn't correct.

A description of VBS records formats:

z/OS 2.4 DFSMS Using Data Sets SC23-6855-40 
https://www-40.ibm.com/servers/resourcelink/svc00100.nsf/pages/zOSV2R4sc236855/$file/idad400_v2r4.pdf
 

pdf page 273 Variable-Length Record Formats (near bottom of page and continues 
on to more pages)

> its just that I don't get proper end of reord. Hence every time I read 
> record, I get random record length (multiple records/half records
> combined)

There aren't any "end of records" in a VBS file.  At the begining of the file 
you know you are at the start of a RDW (Well, BDW/RDW but I'm assuming the FTP 
removed the BDWs).

You can find the next record by going the length specified in the RDW into the 
file -- that is the start of the next RDW.  Continue until you've processed all 
the records.

More help will likely require you to show some code and/or data so we can see 
what is going on...

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to