title: modify and generate new csv file by extracting column values
body: <p>I want to modify on column values of csv file with large dataset. so I had extracted on single column values(here 2nd) then find standard deviation by 2 time iteration of while loop.1st for find mean and 2nd for find standard deviation. standard deviation is multiply with extracted value and that values are replace with it. then generate updated csv file. here when I run code it generate new file successfully with blank file by without while loop iteration. i think there is something problem with both while loop or it is not reading a file. i don't know what it is? standard deviation(σ = √[(Σ(x - MEAN))2 ÷ n]) pls help me</p>
  
  <pre><code>package csvtest7;
      import java.io.File;
      import java.io.FileNotFoundException;
      import java.util.Scanner;
      import java.util.logging.Level;
      import java.util.logging.Logger;
      import java.io.FileWriter;
      import java.io.*;
  
     public class Csvtest7 {
  
    public static void main(String[] args)throws IOException {
      String filename = "ly.csv";
      File file = new File(filename);
      BufferedWriter writer = null;
      try {
          writer = new BufferedWriter(new FileWriter("ly_updated.csv"));
      } 
      catch (IOException e) {
      } 
      try {
          Scanner inputStream = new Scanner(file);
          inputStream.next();
          double Tuple;
          int count=0;
          Tuple = 0; 
          double stddev=0;
          double stddev1;
          double stddev2;
          //double Xi;
          double MEAN;
          double standarddeviation;
   while (inputStream.hasNext()) {
          String data = inputStream.next();
          String[] values = data.split(";");
          double balance = Double.parseDouble(values[2]);
          balance = balance + 1;
           Tuple += balance ;
            }
          MEAN=Tuple/count;
   while (inputStream.hasNext()) {
          String data = inputStream.next();         
          String[] values = data.split(";");
          double balance = Double.parseDouble(values[2]);
          stddev=balance-MEAN;
          stddev1=(stddev*stddev);
          stddev2=(stddev1/count);
          standarddeviation=Math.sqrt(stddev2);       
          balance=standarddeviation*balance;
          values[2] = String.valueOf(balance);
  
  
          // iterate through the values and build a string out of them
          StringBuilder sb = new StringBuilder();
          //  String newData = sb.toString();
          for (int i = 0; i &lt; values.length; i++) {
                  sb.append(values[i]);
                  if (i &lt; values.length - 1) {
                      sb.append(";");
                  }
  
              }
          // get the new string
          System.out.println(sb.toString());
          writer.write(sb.toString()+"\n");
              }
          writer.close();
          inputStream.close();
      } catch (FileNotFoundException ex) {
          Logger.getLogger(Csvtest7.class.getName()).log(Level.SEVERE, null, ex);
      }
  
  
  }
  </code></pre>