۱. آپلود فایل به HDFS:
from hdfs import Client client = Client("hdfs://namenode.example.com:9000") with open("/local/file.txt", "rb") as f: client.write("/hdfs/file.txt", f)
۲. دانلود فایل از HDFS:
from hdfs import Client client = Client("hdfs://namenode.example.com:9000") with open("/local/file.txt", "wb") as f: client.read("/hdfs/file.txt", f)
۳. ایجاد دایرکتوری در HDFS:
from hdfs import Client client = Client("hdfs://namenode.example.com:9000") client.makedirs("/hdfs/dir")
۴. لیست کردن محتویات دایرکتوری در HDFS:
from hdfs import Client client = Client("hdfs://namenode.example.com:9000") for file in client.list("/hdfs/dir"): print(file)