Reputation: 5668
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.
Upvotes: 2
Views: 11473
Reputation: 41
hadoop fs -get /landing/novdata/'2017-01-05 - abc def 5H.csv'
See the single quotes around the filename
Upvotes: 1
Reputation: 763
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.
Upvotes: 4
Reputation: 1569
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
Upvotes: 8
Reputation: 361
The most obvious workaround is to rename the file before storing it on HDFS, don't you think?
Upvotes: 0