Read/Write files on hdfs using Python

风格不统一 提交于 2021-02-11 09:52:10

问题


I am a newbie to Python, I want to read a file from hdfs (which I have achieved).

after reading the file I am doing some string operations and I want to write these modified contents into the output file.

Reading the file I achieved using subprocess (which took a lot of time) since open didn't work for me.

cat = Popen(["hadoop", "fs", "-cat", "/user/hdfs/test-python/input/test_replace"],stdout=PIPE)

Now, how to write to the output file with the modified contents is the question.

Your help is highly appreciated


回答1:


You can use a library for reading and writing to HDFS, like https://github.com/mtth/hdfs



来源:https://stackoverflow.com/questions/37261624/read-write-files-on-hdfs-using-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!