Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i output hadoop result in csv format

I need to output my hadoop result in .csv format. how will i do this? My code :https://github.com/studhadoop/xml/blob/master/XmlParser11.java

should i simply include csvoutputFormat in my code. I am using mapreduce API

myjob.sh

bin/hadoop jar /var/root/ALA/ala_jar/clsperformance.jar ala.clsperf.ClsPerf /user/root/ala_xmlrpt/Amrita\ Vidyalayam\,\ Karwar_Class\ 1\ B_ENG.xml  /user/root/ala_xmlrpt-outputshell4

bin/hadoop fs -get /user/root/ala_xmlrpt-outputshell4/part-r-00000 /Users/jobsubmit


cat /Users/jobsubmit/part-r-00000 /Users/jobsubmit/output.csv

SOLUTION

ys i was missing > in cat

cat /Users/jobsubmit/part-r-00000> /Users/jobsubmit/output.csv
like image 766
Unmesha Sreeveni U.B Avatar asked May 02 '13 03:05

Unmesha Sreeveni U.B


1 Answers

You can use TextOutputFormat. The default key/ value separator is a tab character. You can change the separator by setting the property "mapred.textoutputformat.separatorText" in your driver.

conf.set("mapred.textoutputformat.separatorText", ",");
like image 117
Rags Avatar answered Sep 18 '22 00:09

Rags