| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/../generated/pyarrow.fs.copy_files.html | [Back] [Original] |
Section Navigation
Copy files between FileSystems.
This functions allows you to recursively copy directories of files from one file system to another, such as from S3 to your local machine.
strSource file path or URI to a single file or directory. If a directory, files will be copied recursively from this path.
strDestination file path or URI. If source is a file, destination is also interpreted as the destination file (not directory). Directories will be created as necessary.
FileSystem, optionalSource filesystem, needs to be specified if source is not a URI, otherwise inferred.
FileSystem, optionalDestination filesystem, needs to be specified if destination is not a URI, otherwise inferred.
int, default 1MBThe maximum size of block to read before flushing to the destination file. A larger chunk_size will use more memory while copying but may help accommodate high latency FileSystems.
TrueWhether to use multiple threads to accelerate copying.
Examples
Inspect an S3 buckets files:
>>> s3, path = fs.FileSystem.from_uri(
... "s3://registry.opendata.aws/roda/ndjson/")
>>> selector = fs.FileSelector(path)
>>> s3.get_file_info(selector)
[<FileInfo for 'registry.opendata.aws/roda/ndjson/index.ndjson':...]
Copy one file from S3 bucket to a local directory:
>>> fs.copy_files("s3://registry.opendata.aws/roda/ndjson/index.ndjson",
... f"file:///{local_path}/index_copy.ndjson")
>>> fs.LocalFileSystem().get_file_info(str(local_path)+
... '/index_copy.ndjson')
<FileInfo for '.../index_copy.ndjson': type=FileType.File, size=...>
Copy file using a FileSystem object:
>>> fs.copy_files("registry.opendata.aws/roda/ndjson/index.ndjson",
... f"file:///{local_path}/index_copy.ndjson",
... source_filesystem=fs.S3FileSystem())
Copyright 2016-2026 Apache Software Foundation.
Apache Arrow, Arrow, Apache, the Apache logo, and the Apache Arrow project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
Created using Sphinx 9.1.0.
Built with the PyData Sphinx Theme 0.20.0.
| Web Proxy Viewer | New URL | Original Page |