提取特征向量

时间:2018-03-29 17:49:34

标签: java vector

从csv文件中获取特征向量,

我已经制作了一个代码,在我接触到这个代码的老师助手的帮助下将我的数据表读入eclipse。这是我的代码,用于读取数据和获取特征向量。,但我得到的异常是是(线程中的异常" main" java.lang.NumberFormatException:非法嵌入符号字符)...以下是输入和输出应该是什么的示例:

Desired input/output

 public static void main(String[] args) {

        String csvFile = "D:\\projcet\\data.csv";

        //BigInteger a =BigInteger.ZERO;
        String line = "";
        String cvsSplitBy = ",";

        try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {

            line =br.readLine();
            while ((line = br.readLine()) != null) {

                // use comma as separator
                String[] a = line.split(cvsSplitBy);


                System.out.println("\""+a[0] + "\"," +"\""+a[1] + "\","+"\""+a[2] + "\","+"\""+a[3] + "\","+"\""+a[4] + "\","+"\""+a[5] + "\","+"\""+a[6] + "\","+"\""+a[7] + "\","
                        +"{" + "" + new BigInteger(a[1].trim()).bitCount() + "," 
                        + new BigInteger(a[4].trim()).bitCount() + ","
                        + new BigInteger(a[5].trim()).bitCount() + ","
                        + new BigInteger(a[6].trim()).bitCount() + ","
                        + new BigInteger(a[7].trim()).bitCount() + ".....}");
            }

        } catch (IOException e) {
            e.printStackTrace();
        }                     

}

0 个答案:

没有答案