title: ArrayIndexOutofBounds when reading empty cells in csv MapReduce
body: <p>I am trying to run MapReduce program for the below data.</p>
  
  <p><a href="https://i.stack.imgur.com/vYA0Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vYA0Z.png" alt="enter image description here"></a></p>
  
  <p>This is my mapper code:</p>
  
  <pre><code>@Override
  protected void map(Object key, Text value, Mapper.Context context) throws IOException, ArrayIndexOutOfBoundsException,InterruptedException {
      String tokens[]=value.toString().split(",");
      if(tokens[6]!=null){
          context.write(new Text(tokens[6]), new IntWritable(1));
      }
  
  }
  </code></pre>
  
  <p>As some of my cell data is empty, when I tried to read the column Carrier_delay I get the error below. Please advise.</p>
  
  <pre><code>17/04/13 20:45:29 INFO mapreduce.Job: Task Id : attempt_1491849620104_0017_m_000000_0, Status : FAILED
  Error: java.lang.ArrayIndexOutOfBoundsException: 6
      at Test.TestMapper.map(TestMapper.java:22)
      at Test.TestMapper.map(TestMapper.java:17)
      at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145)
      at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
      at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340)
      at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.Subject.doAs(Subject.java:422)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/TMiVe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TMiVe.png" alt="enter image description here"></a></p>
  
  <pre><code>Configuration conf = new Configuration();
  Job job = Job.getInstance(conf,"IP Access");
  job.setJarByClass(Test.class);
  job.setMapperClass(TestMapper.class);
  
  job.setMapOutputKeyClass(Text.class);
  job.setMapOutputValueClass(IntWritable.class);
  
  job.setReducerClass(TestReducer.class);
  job.setOutputKeyClass(Text.class);
  job.setOutputValueClass(IntWritable.class);
  
  FileInputFormat.addInputPath(job, new Path(args[0]));
  FileOutputFormat.setOutputPath(job, new Path(args[1]));
  System.exit(job.waitForCompletion(true) ? 0 : 1);
  </code></pre>