How to csvwrite an array in HDFS

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,

 Respuesta aceptada

Kojiro Saito
Kojiro Saito el 16 de En. de 2018
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 comentarios

Amr Munshi
Amr Munshi el 16 de En. de 2018
Thanks! it worked. Do you know how to read the .seq file from HDFS?
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 .
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
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 el 17 de En. de 2018
Thanks a lot! I'm so grateful to you
lov kumar
lov kumar el 7 de Jun. de 2019
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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Centro de ayuda y File Exchange.

Preguntada:

el 16 de En. de 2018

Comentada:

el 7 de Jun. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by