Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.java > #9381

sort array column 5

Newsgroups it.comp.java
Date 2021-03-09 09:54 -0800
Message-ID <541bbf2b-8a0c-4fe7-ba6b-f703ccca25f8n@googlegroups.com> (permalink)
Subject sort array column 5
From bender bender <voodoo.bender@gmail.com>

Show all headers | View raw


Hi, 
I'm scripting a java program that sort descending data from csv file

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;


public class javaRes {

// Sort column csv

 static class OrderColumn

 {
     public static void main (String[] args) throws IOException

     {
         File fileCSV = new File("Analisi_2018.csv");
         BufferedReader streamCSV = new BufferedReader(new FileReader(fileCSV));

         //Instantiating the File class
      File file = new File("provvi.csv");
      //Instantiating the PrintStream class
      PrintStream stream = new PrintStream(file);
      System.setOut(stream);

         String lineRead;
         
         int tmpRowCount=0;

         while( (lineRead=streamCSV.readLine()) != null )
         {
             tmpRowCount++;
         }

         streamCSV.close();

         System.out.println("Rowcount= "+tmpRowCount);

         String[] fileArray=new String[tmpRowCount];

         streamCSV = new BufferedReader(new FileReader(fileCSV));

         int tmpI=0;

         while( (lineRead=streamCSV.readLine()) != null )

         {

             fileArray[tmpI++]=lineRead;

         }
         //SORT HERE


    Arrays.sort(fileArray, Collections.reverseOrder());

     for (String number : fileArray) {
        System.out.println(number);
     }

   

         System.exit(1);

     }

 }

}

I obtain a new .csv 
but sorting about column 1
I would order with target column 6
How could fix it using this scheme of program 

regards

A

Back to it.comp.java | Previous | NextNext in thread | Find similar


Thread

sort array column 5 bender bender <voodoo.bender@gmail.com> - 2021-03-09 09:54 -0800
  Re: sort array column 5 "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2021-03-10 07:48 +0100

csiph-web