[Tutor] Reading individual file from tar file as a file object
xboxmuncher at gmail.com
Thu Oct 8 22:10:58 CEST 2009
I have a large tar.bz2 file that I want to extract certain files directly to
an FTP path.
Since the extract() method doesn't accept ftp paths... I wanted to read the
files from the tar file like a file object or file I/O stream.
Is there a way to do this?
Here's my pseudocode:
#write it to a file in FTP
tar = tarfile.open("HUGE_FILE_OVER_5GB.tar.bz2", "r:bz2")
readSize = 50
for tarInfo in tar:
fileSize = tarInfo.size
#prepare for loop to read specific file inside tar
if readSize > fileSize
readSize = fileSize
readIterations = fileSize/readSize
#loop & read file
for i in range(readIterations):
#catch remainder of file
lastReadSize = fileSize - (readSize * readIterations)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor