Hi,
I have Matlab connected to a Hadoop cluster. I want to save an array as a csv file to HDFS. The only commend I found was:
location = 'hdfs://master/user/savecsvfile';
write(location, Array1 );
Then I check the HDFS respiratory to find a file "part-1-snapshot.seq" and the contents are different from what Array1 is.
Thanks,

 採用された回答

Kojiro Saito
Kojiro Saito 2018 年 1 月 16 日

1 投票

write command is able to write only tall array as .seq file. So, if you want to save csv files to HDFS, you should first save csv files on locla then upload to HDFS using Hadoop commands. From MATLAB,
csvwrite('hoge.csv', Array1);
!hadoop fs -copyFromLocal ./hoge.csv /user/savecsvfile

6 件のコメント

Amr Munshi
Amr Munshi 2018 年 1 月 16 日
Thanks! it worked. Do you know how to read the .seq file from HDFS?
Kojiro Saito
Kojiro Saito 2018 年 1 月 16 日
In order to read .seq files from HDFS, we use datastore. For example,
location = 'hdfs://master/some/path/to/seqfiles';
ds = datastore(location);
For detail of datastore, please see this doc .
Amr Munshi
Amr Munshi 2018 年 1 月 16 日
Thanks again! Sorry to be annoying but is there a way to add the timestamp to this command (to have it saved as "savecsvfile16-01-18 14:10"):
!hadoop fs -copyFromLocal ./hoge.csv /user/savecsvfile
Kojiro Saito
Kojiro Saito 2018 年 1 月 16 日
Do you want to create HDFS directory with timestamp? If so, try this.
formatOut = 'dd-mm-yy_HHMM';
command = ['hadoop fs -copyFromLocal ./hoge.csv /user/savecsvfile' datestr(now,formatOut)];
status = system(command);
In this case, a csv file will be stored in savecsvfile16-01-18_1410.
Amr Munshi
Amr Munshi 2018 年 1 月 17 日
Thanks a lot! I'm so grateful to you
lov kumar
lov kumar 2019 年 6 月 7 日
How to connect matlab to hadoop cluster.
How to fix this issue:
Parallel mapreduce execution on the Hadoop cluster:
********************************
* MAPREDUCE PROGRESS *
********************************
Map 0% Reduce 0%
Error using mapreduce (line 125)
The HADOOP job failed to submit. It is possible that there is some issue with the HADOOP configuration.
OS: windows

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by