Skip to content

Instantly share code, notes, and snippets.

@hyunjun
Created April 28, 2020 09:21
Show Gist options
  • Save hyunjun/8f2080557e7b7b261861a260d9225bb4 to your computer and use it in GitHub Desktop.
Save hyunjun/8f2080557e7b7b261861a260d9225bb4 to your computer and use it in GitHub Desktop.
pywebhdfs
from pywebhdfs.webhdfs import PyWebHdfsClient
client = PyWebHdfsClient(host='namenode-1.server.ip.address', port=14000, user_name='<user name>')
r = client.read_file(<file name>)
for l in r.decode('utf-8').split('\n'):
l = l.strip()
if 0 == len(l):
continue
# work
client.create_file(<file name>, '\n'.join([line for line in lines]).encode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment