Search code examples
pythonpython-3.xfilecopylarge-files

How do I copy a large file in chunks from a source file to a destination file using python?


The file can be say 20GB. The traditional approach of importing,reading a file and then writing to another file is not feasible.


Solution

  • The shutil module has a function designed for this purpose:

    import shutil
    shutil.copy(src, dst)