Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Latest commit

 

History

History
33 lines (19 loc) · 654 Bytes

quickstart.rst

File metadata and controls

33 lines (19 loc) · 654 Bytes

Quickstart

Import hdfs3 and connect to an HDFS cluster:

>>> from hdfs3 import HDFileSystem
>>> hdfs = HDFileSystem(host='localhost', port=8020)

Write data to file:

>>> with hdfs.open('/tmp/myfile.txt', 'wb') as f:
...     f.write(b'Hello, world!')

Read data back from file:

>>> with hdfs.open('/tmp/myfile.txt') as f:
...     print(f.read())

Interact with files on HDFS:

>>> hdfs.ls('/tmp')

>>> hdfs.put('local-file.txt', '/tmp/remote-file.txt')

>>> hdfs.cp('/tmp/remote-file.txt', '/tmp/copied-file.txt')