0

我需要读入一个 csv 文件,对其进行解析,然后根据这些参数对值进行排序:

  1. 畅销产品前10名
  2. 表现最好的分支机构
  3. 表现最差的分支
  4. 获得最多销售额的员工

到目前为止,这是我的代码,有关如何对其进行排序的任何建议?

import java.io.*;

public class CSV {
public static void main(String[] args) throws IOException {
    try (BufferedReader CSVFile = new BufferedReader(new FileReader("/K:/ConnexicaWork/data/data.csv"))) {
        String[] dataArray = null;
        String data = CSVFile.readLine(); // Read first line.

        while (data != null) {
            data = data.replace(",00", ".00");
            dataArray = data.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)"); //split on the comma only if that comma has zero, or an even number of quotes in ahead of it.
            for (String item : dataArray) {
                System.out.print(dataArray[34] + " # ");
            }
            System.out.println(); // Print the data line.
            data = CSVFile.readLine(); // Read next line of data.
        }
    }


    System.out.println();  // End the printout with a blank line.

}
}
4

0 回答 0