I am writing a program that takes in a CSV file and makes a table out of the content from it. Then I apply a filter that will eliminate the bad entries in it, and I want to store those into a different ArrayList using the .add(originalTable())
The problem I am having is I want to apply different filters and get different ArrayList each with the incremented number. So the OriginalTable is filter0 than filter1 than filter2. The problem I am running into is how do I increment the number of Filter over one ?
State Population Death
1 10000 10
2 10001 10
3 10002 0
4 1200 100
5 1 900
6 1213 900
Okay so I have data like this in my Table which is just an arrayList of ArrayList, ArrayList one being the rows stored into the columns. Now let say I apply the filter that I want deaths less than or equal to 10 deaths and this should give me another “table” called filter which will give me:
State Population Death
1 10000 10
2 10001 10
3 10002 0
This will be called filter1 now I apply another filter to this saying let me have only only with population bigger than 10,000 population and this is will result in another “table” called filter2.
Which would look something like this:
State Population Death
2 10001 10
3 10002 0
I don’t know how to increment it from filter0 to filter1 to filter2 and they have to be arrayList of ArrayList each time. Thank you guys so much! 🙂
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));
}
}
You should explore the guava library. The library isn’t huge and provides several ways to solve such problems using oops principles; will help you maintain good object structure.