The operation of python access hdfs

pip install hdfs

python read hdfs directory or file

import hdfs
 
client =hdfs.Client("http://10.10.1.4:50070")
fileDir="/user/hive/warehouse/house.db/dm_house/dt=201800909"try:
 status=client.status(fileDir,False)if status:print(status)
 rst=client.download(fileDir,"/home/dev/gewei")print(rst)
exception Exception as e:print(e)

Supplementary knowledge: Webhdfs cannot be found when accessing hdfs with python

It may be that the webhdfs service is not turned on

Add attributes to the hdfs-site.xml file:

< property  
 < name dfs.webhdfs.enabled</name  
 < value true</value  
< /property  

You can use the following command to detect,

Get a list of directories:

curl -i “http://Hadoop:50070/webhdfs/v1/?user.name=hadoop&op=LISTSTATUS”

The above operation of python access hdfs is all the content shared by the editor, I hope to give you a reference.

Recommended Posts

The operation of python access hdfs
Consolidate the foundation of Python (4)
Consolidate the foundation of Python(7)
Consolidate the foundation of Python(6)
Consolidate the foundation of Python(5)
Consolidate the foundation of Python (3)
Detailed explanation of the attribute access process of Python objects
The usage of wheel in python
Python preliminary implementation of word2vec operation
Learn the hard core operation of Python in one minute
Python handles the 4 wheels of Chinese
Some examples of python operation redis
The premise of Python string pooling
Secrets of the new features of Python 3.8
The father of Python joins Microsoft
The usage of tuples in python
End the method of running python
Understanding the meaning of rb in python
Can Python implement the structure of the stack?
Learn the basics of python interactive mode
Logistic regression at the bottom of python
Solve the conflict of multiple versions of python
Python implements the sum of fractional sequences
What is the id function of python
Where is the pip path of python3
The essence of Python language: Itertools library
What are the advantages of python language
The specific method of python instantiation object
python3 realizes the function of mask drawing
What is the prospect of python development
The specific method of python import library
Solve the conflict of multiple versions of python
7 features of Python3.9
Python file operation
2.1 The Python Interpreter (python interpreter)
python operation kafka
What is the function of adb in python
Detailed explanation of the principle of Python super() method
The difference between the syntax of java and python
Python realizes the development of student management system
Python implements the shuffling of the cards in Doudizhu
The meaning and usage of lists in python
Solve the problem of python running startup error
Can the value of the python dictionary be modified?
Python implements the source code of the snake game
Detailed explanation of the usage of Python decimal module
Analysis of common methods of Python operation Jira library
How about learning python at the age of 27?
The consequences of uninstalling python in ubuntu, very
Python writes the game implementation of fishing master
[898] python get the intersection of two lists | union | difference
Detailed explanation of the principle of Python function parameter classification
What is the advantage of python over corporate language
A brief summary of the difference between Python2 and Python3
Detailed explanation of the principle of Python timer thread pool
Solve the problem of python compiling and installing ssl
Detailed explanation of the implementation steps of Python interface development
How does python call the key of a dictionary
Python crawls the full set of skins of the king pesticide
How to understand the introduction of packages in Python
Basics of Python syntax