본문 바로가기
Hadoop

Python으로 HDFS 파일 읽기(feat. Ubuntu)

by 집못가는프로그래머 2021. 9. 7.

<Python으로 HDFS에 있는 csv파일을 읽어오는 예시>

 

import pandas as pd

from hdfs import InsecureClient   # Python에서 hdfs를 사용하기 위한 모듈 import

 

client_hdfs = InsecureClient('http://localhost:9870')   #namenode 의 웹 인터페이스

with client_hdfs.read('/user/csv/sample.csv') as reader :

   df = pd.read_csv('reader,index_col=0)

print(df)

댓글