0
一类项目工作的第一个字符,它读入一个数组后不会与数据的麻烦。导入和拆分CSV输入,帮助有需要的只读取的
Excel电子表格,我需要直降读取列注意只有在每一个块中的第一位。当我拆分列时,它是一个没有空格的连续字符串,所以我不能计算出如何计算第一个数字而不是计算每个数字(如现在的代码)。 例子:(11,20,296)被分割,成为 “1120296”
final int[] benfordLaw = {0, 30, 18, 13, 10, 8, 7, 6, 5, 5};
int[] actualPrecent = new int[10];
int benfordScore = 0;
float[] countForNum = new float[10];
float totalCount = 0;
//This while loop will read through each line of the file
while (scan.hasNextLine()) {
// This statement reads in the next line of the file.
String line = scan.nextLine();
String[] values = line.split(",(?=(?:(?:[^\"]*+\"){2})*+[^\"]*+$)");
//12-15 is the column #'s
for (int i = 12; i < 15; ++i) {
for (int j = 0; j < values[i].length(); j++) {
char charA = values[i].charAt(j);
for (int k = 1; k <= 9; ++k){
char compare = (char)(k + '0');
if (charA == compare) {
++countForNum[k];
++totalCount;
}
}
}
}
}