Created
December 28, 2011 20:07
-
-
Save drelu/1529478 to your computer and use it in GitHub Desktop.
WebHDFS Python Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from webhdfs.webhdfs import WebHDFS | |
import os, tempfile | |
import time | |
webhdfs = WebHDFS("localhost", 50070, "luckow") | |
webhdfs.mkdir("/hello-world/") | |
# create a temporary file | |
f = tempfile.NamedTemporaryFile() | |
f.write(b'Hello world!\n') | |
f.flush() | |
print "Upload file: " + f.name | |
webhdfs.copyFromLocal(f.name, | |
"/hello-world/test.txt") | |
webhdfs.copyToLocal("/hello-world/test.txt", | |
"/tmp/test1.txt") | |
for i in webhdfs.listdir("/"): | |
print str(i) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do we use this with kerberos