package com.mystudy.pxkDazuoye;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Mapper;

public class MyMapper extends Mapper<LongWritable, Text, Text, Text> {

@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
    if (key.get() > 0) { // 排除表头
        String[] fields = value.toString().split(',');
        String firstName = fields[1];
        String lastName = fields[2];
        String emailAddress = fields[3];
        Text outputKey = new Text(firstName + ',' + lastName);
        Text outputValue = new Text(fields[0] + ';' + firstName + ' ' + lastName + ';' + emailAddress);
        context.write(outputKey, outputValue);
    }
}

}

Hadoop MapReduce: 处理 CSV 数据并提取关键信息

原文地址: https://www.cveoy.top/t/topic/oJRT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录