[Info-vax] Fun with file attribrutes
Jojimbo
jjgessling at gmail.com
Fri Dec 23 16:46:50 EST 2011
One of our programmers came to me for help reading a file that he had
received via SFTP. This file had the records delimited by ~
characters. Full directory information:
$ dir/full test.txt
Directory USERS:[USER.998]
TEST.TXT;1 File ID: (33285,3,0)
Size: 147KB/341KB Owner: [IDXUSER,USER]
Created: 23-DEC-2011 13:26:41.92
Revised: 23-DEC-2011 13:26:41.94 (1)
Expires: <None specified>
Backup: <No backup recorded>
Effective: <None specified>
Recording: <None specified>
Accessed: <None specified>
Attributes: <None specified>
Modified: <None specified>
Linkcount: 1
File organization: Sequential
Shelved state: Online
Caching attribute: Writethrough
File attributes: Allocation: 683, Extend: 0, Global buffer count: 0
No version limit
Record format: Stream, maximum 0 bytes, longest 32767 bytes
Record attributes: Carriage return carriage control
RMS attributes: None
Journaling enabled: None
File protection: System:RWED, Owner:RWED, Group:RE, World:
Access Cntrl List: None
Client attributes: None
Total of 1 file, 147KB/341KB
I tried to read it in Python and got this result:
$ python
Python 2.7.2+ (default, Nov 7 2011, 14:45:22) [DECC] on OpenVMS
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('test.txt')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 65535] !ul byte record too large for user's buffer:
'test.txt'
<ctrl>Z
After fooling around for quite a while with convert and setting file
attributes I did this and was able to read the file and split it based
on the ~ characters no problem.
$ set file/attr=(rfm:udf,rat=none) test.txt
$ python
Python 2.7.2+ (default, Nov 7 2011, 14:45:22) [DECC] on OpenVMS
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('test.txt')
>>> s = f.read()
I then split the string s into records like:
>>> lines = s.split('~')
Which gave me an array (lines) that I could write out as a file.
Huh? What did I do? I guess as long as the file can fit into a
Python string then I'm OK.
But I find the whole thing puzzling but I am happy that it solved my
problem.
Regards, Jim
More information about the Info-vax
mailing list