reading files with error

Maurice LING mauriceling at acm.org
Sat Sep 17 21:37:13 EDT 2005


Hi,

I'm trying to read some files (video files) that seems to have some 
errors in it. Basically, I cannot copy it out of discs as that gives me 
an error message but I can still play the file using a media player like 
VLC or QuickTime. I understand that copying a file will also invoke 
checking routines as well, and I am guessing that the file may have some 
parity-bit error or something.

Am I able to use Python to force read the entire file (full length)? 
That is, do not check the read for errors. I know that this is insideous 
in many uses but in media files, it may only result in a skipped frame 
or something. What I've done is something like this:

 >>> f = open('/Volumes/NEW/gameday/morning.dat', 'rb')
 >>> data = f.read()
 >>> o = open('/Users/mauriceling/Desktop/o.dat', 'wb')
 >>> f.close()
 >>> o.write(data)
 >>> o.close()

What I've noticed is this:
1. sometimes it (Python) only reads to roughly the point of initial copy 
error (I try to take note of how far drag-and-drop copying proceeds 
before it fails)
2. sometimes it is able to read pass the drag-and-drop copying 
fail-point but may or may not be full length.

What determines if Python is able to make it pass drag-and-drop copying 
fail-point?

Is there anyway to do what I want, force read full length?

Thanks and cheers
Maurice



More information about the Python-list mailing list