我正在編寫一個程序,它接收一個CSV文件並從其中取出一個表格。然後我應用一個過濾器,將消除其中的錯誤條目,並且我想使用.add(originalTable())將它們存儲到不同的ArrayList中。我遇到的問題是我想要應用不同的過濾器和使用遞增的數字獲得不同的ArrayList。因此,OriginalTable比filter1中的filter1更多地是filter1。我遇到的問題是如何將過濾器的數量增加到一個?如何增加下一個變量?
State Population Death
1 10000 10
2 10001 10
3 10002 0
4 1200 100
5 1 900
6 1213 900
好了,所以我在我的表是剛剛的ArrayList,ArrayList的一個是存儲在列行的ArrayList這樣的數據。現在,讓我們說我申請,我要小於或等於死亡人數10人死亡過濾器,這應該給我一個「表」稱爲過濾器,這將給我:
State Population Death
1 10000 10
2 10001 10
3 10002 0
將其稱爲過濾器1,現在我申請的另一個過濾到這種說法讓我只有超過10,000人口的人口,這將導致另一個名爲filter2的「表」。 這將是這個樣子:
State Population Death
2 10001 10
3 10002 0
我不知道如何從filter0增加它FILTER1到FILTER2,他們必須每一次的ArrayList ArrayList中。非常感謝你們! :)
else if (task.contentEquals("filter")){
String filter = keyboard.nextLine();
String[] filterArray = filter.split(" ");
int colmn = 0;
String predicate ;
String Value = "W";
if(filter.contains("-v ")){
// do the seperate cutoff strings System.out.println("yeah it contains v");
}else{
colmn = Integer.parseInt(filterArray[1]);
predicate = filterArray[2];
//Value = filterArray[3];
System.out.println(colmn +" "+ predicate + " "+Value);
}
for(int i =0; i <table.size(); i++){
if(table.get(i).get(colmn).toString().contains(Value)){
filterTable.add(table.get(i));
System.out.println(table.get(i));
}
}
可否請您張貼一些代碼來詳細說明您的問題? –
濾波器[-v] (<| <= | = | > = |>) 這產生一個新的表格圖,該只包含滿足上specied列specied謂詞。爲新創建的視圖分配下一個可用視圖編號,並將此編號報告給用戶(假設該命令不失敗)。 –
Ashley
什麼樣的「表」?什麼樣的過濾器?您使用的是什麼圖書館?什麼情況下? –