im using a large csv file having large dataset about 17 attribute and approx 40000 rows. i want to write ith position of each rows value in reverse order(1st row ith ","separated value is replace with 40000th ith"," separated...2nd is replace with39999...likewise all)(here i extracted 12th value= ith ).how can i do this pls help me.!!
package demo;
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.*;
/**
*
/**
*
* @author admin
*/
public class Demo {
/**
* @param args the command line arguments
*/
public static void main(String[] args)throws IOException {
String filename = "bank-full.csv";
File file = new File(filename);
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new FileWriter("bank-full_updated.csv"));
}
catch (IOException e) {
}
try {
Scanner inputStream = new Scanner(file);
inputStream.next();
double Tuple;
int count=0;
Tuple = 0;
while (inputStream.hasNext())
{
String data = inputStream.next();
String[] values = data.split(";");
double balance = Double.parseDouble(values[11]);
//balance=balance+1;
values[11] = String.valueOf(balance);
count=count+1;
// iterate through the values and build a string out of them
StringBuilder sb = new StringBuilder();
// String newData = sb.toString();
for (int i = 0; i < values.length; i++) {
sb.append(values[i]);
if (i < 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(Demo.class.getName()).log(Level.SEVERE, null, ex);
}
}
}