如何以 csv 格式输出 hadoop 结果

2022-01-13 00:00:00 csv hadoop mapreduce java

我需要以 .csv 格式输出我的 hadoop 结果.我将如何做到这一点?我的代码:https://github.com/studhadoop/xml/blob/master/XmlParser11.java

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

我是否应该在我的代码中简单地包含 csvoutputFormat.我正在使用 mapreduce API

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

我的工作.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

解决方案

是我失踪了>在猫

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

推荐答案

可以使用TextOutputFormat.默认的键/值分隔符是制表符.您可以通过在驱动程序中设置属性mapred.textoutputformat.separatorText"来更改分隔符.

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", ",");

相关文章