Created
January 13, 2018 21:39
-
-
Save shiracamus/e713e219c8c7d015a147916f7e984298 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def divide_file(filePath, chunkSize): | |
def read(): | |
with open(filePath, 'rb') as f: | |
while True: | |
data = f.read(chunkSize) | |
if len(data) == 0: | |
return | |
yield data | |
def write(filePath, data): | |
with open(filePath, 'wb') as f: | |
f.write(data) | |
def divide(): | |
for i, data in enumerate(read()): | |
saveFilePath = '%s.%s' % (filePath, i) | |
write(saveFilePath, data) | |
yield saveFilePath | |
return list(divide()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment