我正在尝试使用map reduce来解析csv中的特定列。我的csv中有一些空单元格。当我试图运行它时会显示一些异常。但是当我运行一个没有空单元格的csv时,我得到了我的输出。
sss xx asdas sddf
saq asdsds sdsds
ewe zz asdsd
aaa qq adsd ssdds
我的csv看起来像那样,我的mapper输出必须像这样
sss xx sddf 1
saq sdsds 1
ewe zz 1
aaa qq ssdds 1
我的Mapper代码
public class DataMap extends MapReduceBase implements Mapper<
LongWritable,Text,Text,IntWritable> {
public final static IntWritable one = new IntWritable(1);
@Override
public void map(LongWritable key, Text value,
OutputCollector<Text, Text> output, Reporter r)
throws IOException {
String a = value.toString();
String[] temp = a.split("\t");
output.collect(new Text(temp[0] + "\t" +temp[1] + "\t" +temp[3]), new IntWritable(a));
}
}
我怎么能过来这个。