Export to GitHub

libpyhdfs - APIs.wiki


Note This page may be out of date. For more precise information, see help(pyhdfs) in python. The contents of this page are also generated by help(pyhdfs.xxx).


rename(fs, oldpath, newpath) -> None

Rename a file (direcory)


exists(fs, path) -> True or False

Checks if a given path exsits on the hdfs


stat(fs, path) -> fileinfo(type, size, lastmodify, lastaccess)

Get information about a path


connect(host, port) -> fs

Connect to a hdfs file system


flush(fs, hdfsfile) -> None

Flush the data


close(fs, hdfsfile) -> True or False

Close a hdfs file


pread(fs, hdfsfile, offset[, size]) -> similar to read, read data from given position


seek(fs, hdfsfile, offset) -> True or False

Seek to given offset in open file in read-only mode


disconnect(fs) -> True or False

Disconnect from hdfs file system


open(fs, path[, mode[, bufsize[, replication[, blksiz]]]]) -> hdfs-file

Open a hdfs file in given mode ("r" or "w"), default is read-only


mkdir(fs, path) -> True or False

Make the given path and all non-existent parents into directories


write(fs, hdfsfile, str) -> byteswritten

Write data into an open file


tell(fs, hdfsfile) -> int

Get the current offset in the file, in bytes. -1 is returned on error


listdir(fs, path) -> stats

Get list of files/directories of a given directory-path. Returns a list of dict object containing {kind, name, last_mod, size, replication, block_size, owner, group, permissions, last_access}


get(fs, rpath, lpath) -> None

Copy a file from hdfs to local


read(fs, hdfsfile[, size]) -> read at most min(2M, size) bytes, returned as a string

If the size argument is <=0 or omitted, read at most 2M bytes. When EOF is reached, empty string will be returned


getcwd(fs) -> path

Return a string representing the current working directory.


put(fs, lpath, rpath) -> None

Copy a file from local to hdfs


utime(fs, path, modtime, actime) -> True or False

Change file last access and modification times


chdir(fs, path) -> True or False

Set the working directory. The `path' can be a non-exist directory. All relative paths will be resolved relative to it.


delete(fs, path) -> None

Delete a file (directory)