python--upload file into HDFS loads files into HDFS

Simulation: https://creativedata.atlassian.net/wiki/spaces/SAP/pages/61177860/Python+-+Read+Write+files+from+HDFS

import pandas as pd
from hdfs import InsecureClient
import os

client_hdfs = InsecureClient('http://(your name node ip adress):50070/',user='hadoop')
# Creating a simple Pandas DataFrame
liste_hello = ['hello1','hello2']
liste_world = ['world1','world2']
df = pd.DataFrame(data = {'hello' : liste_hello, 'world': liste_world})
 
# Writing Dataframe to hdfs
with client_hdfs.write('/Learn/input/helloworld.csv', encoding = 'utf-8') as writer:
    df.to_csv(writer)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324880828&siteId=291194637