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


Groups > it.comp.java > #9381

sort array column 5

X-Received by 2002:ae9:f81a:: with SMTP id x26mr25563732qkh.497.1615312480221; Tue, 09 Mar 2021 09:54:40 -0800 (PST)
X-Received by 2002:a37:bd7:: with SMTP id 206mr19915448qkl.284.1615312480006; Tue, 09 Mar 2021 09:54:40 -0800 (PST)
Path csiph.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news.uzoreto.com!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups it.comp.java
Date Tue, 9 Mar 2021 09:54:39 -0800 (PST)
Injection-Info google-groups.googlegroups.com; posting-host=151.46.19.26; posting-account=-eF7WAoAAACt5PDSlI-9XEDar7KgU_BQ
NNTP-Posting-Host 151.46.19.26
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <541bbf2b-8a0c-4fe7-ba6b-f703ccca25f8n@googlegroups.com> (permalink)
Subject sort array column 5
From bender bender <voodoo.bender@gmail.com>
Injection-Date Tue, 09 Mar 2021 17:54:40 +0000
Content-Type text/plain; charset="UTF-8"
Lines 82
Xref csiph.com it.comp.java:9381

Show key headers only | 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