将有字段缺失的数据删除掉
分析
将清洗后的数据导入数据库表中
筛选出新增确诊人数最多的前三天的数据
map代码
效果
还有一种思路 把缺失的数据注释
map代码
package test7;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import java.io.IOException;
public class test11 extends Mapper <LongWritable, Text,Text, NullWritable>{
Text k=new Text();
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line=value.toString();
String[] word=line.split(",");
String end = "";
int i = 0;
if (word.length==5){
for ( i=0;i<=4;i++ ){
if(word[i].equals("")){
word[0]= "--"+word[0];
}
}
}
else if(word.length<5){
word[0]="--"+word[0];
}
for (String item: word){
end = end + item + ",";
}
end=end.substring(0,end.length()-1);
k.set(end);
context.write(k,NullWritable.get());
}
}
效果