with client.write(conf.hdfs_location+'/'+ conf.filename, encoding='utf-8', buffersize=10000000) as f:
writer = csv.writer(f, delimiter=conf.separator)
for i in tqdm(10000000000):
row = [column.get_value() for column in conf.columns]
writer.writerow(row)
# Loading a file in memory.
with client.read('features') as reader:
features = reader.read()
# Directly deserializing a JSON object.
with client.read('model.json', encoding='utf-8') as reader:
from json import load
model = load(reader)
4条答案
按热度按时间u1ehiz5o1#
当我使用hdfscli的write方法时是不是非常慢?有没有什么方法可以加快使用hdfscli的速度?
多谢了。
2w3rbyxf2#
使用python将本地文件写入hdfs的两种方法:
一种方法是使用hdfs python包:
代码段:
输出位置:'/user/madhuc/hdfswritedata/sample.csv'
另一种方法是使用管道的子进程python包
代码表:
thigvfpy3#
hdfs dfs -put
不需要在本地创建文件。而且,不需要在hdfs上创建零字节文件(touchz
)并附加到(appendToFile
). 您可以直接在hdfs上编写文件,如下所示:按回车键。在命令提示下,输入要放入文件中的文本。完成后,说
Ctrl+D
.fwzugrvs4#
你试过hdfscli吗?
引用读写文件的段落: