Using Python for file packing

A

Aaron Scott

I'm working on a Python application right now that uses a large number
of audio assets. Instead of having a directory full of audio, I'd like
to pack all the audio into a single file. Is there any easy way to do
this in Python? My first instinct was to attempt to pickle all the
audio data, but something tells me that that experiment would only end
in tears.
 
K

Kushal Kumaran

I'm working on a Python application right now that uses a large number
of audio assets. Instead of having a directory full of audio, I'd like
to pack all the audio into a single file. Is there any easy way to do
this in Python? My first instinct was to attempt to pickle all the
audio data, but something tells me that that experiment would only end
in tears.

Do you mean like a zip or tar file?

http://docs.python.org/library/zipfile.html
http://docs.python.org/library/tarfile.html
 
M

MRAB

Scott said:
You will find the zip format works better if you are compressing. The
zipfile compression is per file in the archive, rather than applied to
the entire archive (as in tarfile). The results of the tar format
decision is that extracting the last file in a .tgz (.tar.gz) or
.tar.bz2 (sometimes called .tbz) requires the expansion of the entire
archive, while extraction on a .zip is reposition, read, and possibly
expand.
If the audio is already compressed then a zipfile probably won't be able
to compress it any more.
 
N

Nobody

You will find the zip format works better if you are compressing. The
zipfile compression is per file in the archive, rather than applied to
the entire archive (as in tarfile). The results of the tar format
decision is that extracting the last file in a .tgz (.tar.gz) or
.tar.bz2 (sometimes called .tbz) requires the expansion of the entire
archive, while extraction on a .zip is reposition, read, and possibly
expand.

Even without compression, the tar format is ill-suited to random access.
If you can choose the format, use a zip file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top