Put file on HDFS with spaces in name

廉价感情. 提交于 2019-12-01 09:26:19

问题


I have a file named file name(1).zip (with the space and parentheses in it) and I want to put this file on the HDFS. But everytime I try to put it via hadoop fs -put ... , I get a an exception.

I have even tried to add quotes around the file and even tried to escape the space and parentheses but it doesn't work.

hduser@localhost:/tmp$ hadoop fs -put file\ name\(1\).zip /tmp/one
15/06/05 15:57:46 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
put: unexpected URISyntaxException

hduser@localhost:/tmp$ hadoop fs -put "file\ name\(1\).zip" /tmp/one/
15/06/05 15:59:19 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
put: unexpected URISyntaxException

hduser@localhost:/tmp$ hadoop fs -put "file name(1).zip" /tmp/one/
15/06/05 16:00:36 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
put: unexpected URISyntaxException

Is there any work-around to put such files on the HDFS or am I missing something here.


回答1:


The most obvious workaround is to rename the file before storing it on HDFS, don't you think?




回答2:


Replace the spaces with %20.

The percent-encoding for space is %20

Use

hadoop fs -put first%20name.zip /tmp/one

instead of

hadoop fs -put first name.zip /tmp/one



回答3:


HDFS is totally fine with spaces in the file or directory names.

It is the hdfs that does not support putting a file from local disk with spaces in its file name. But there is a trick to achieve this ( reference ):

cat file\ name\(1\).zip | hadoop fs -put - "/tmp/one/file name(1).zip"

Hope this helps those that need this.




回答4:


try

fs -put 'file name(1).zip' tmp/one



回答5:


hadoop fs -get /landing/novdata/'2017-01-05 - abc def 5H.csv'

See the single quotes around the filename



来源:https://stackoverflow.com/questions/30669210/put-file-on-hdfs-with-spaces-in-name

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