Aloha stackoverflow denizens!
I am writing an application that will compress a folder and its contents to an archive (potentially a tarfile, but I am open to other formats). This, I know how to do using native python modules. The part that I am not sure how to do would be to break up the tarfile to either x-number of different file objects, or a series that have a max size of y.
I have googled about and RTFM’d, but have not noticed some native method that would provide a similar function.
I have considered something along the lines of:
def fileshrink(filename, numberoflines):
f=open(filename)
g=0
while f.hasnext():
newfile="newfile"+g+".txt
g.open(newfile)
for line in range(numberoflines):
g.write(line)
but I do not think it will work on things like *.docs, *.exes, or other non text filetypes.
Can you offer me some insight into how to best procede?
file.read()will allow you to read an arbitrary number of bytes from the file.