Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[]args)throws IOException
- {
- BufferedReader br = new BufferedReader(new FileReader("PeopleList.csv"));
- String line,city,state;
- String delim="[,]";
- String del="[ ]";
- ArrayList<Place> place=new ArrayList<Place>();
- //Place fakePlace=new Place();
- //place.add(fakePlace);
- line=br.readLine();
- while(line != null)
- {
- String[]tokens = line.split(delim);
- if(tokens.length==4)
- {
- String[]tok=tokens[0].split(del);
- //START HERE
- if(!place.isEmpty())
- {
- //does this place exist?
- int x = -1;
- //loop through all places and do manual check for place name
- for(int i=0; i<place.size(); i++)
- {
- Place lugar = place.get(i);
- if(lugar.getState().equals(tokens[3]))
- {
- x = i;
- break;
- }
- }
- if(x>=0)
- {
- //it does exist, add the city and state to that place
- Place lugar = place.get(x);
- lugar.addCity(tokens[2]);
- lugar.addPeople(line);//(tok[0]+" "+tok[1]+" "+tok[tok.length-1]));
- }
- else
- {
- place.add(new Place(tokens[2],tokens[3],line));//tok[0],tok[1],tok[tok.length-1]));
- }
- /*
- if(!place.contains(tokens[3]))
- {
- place.add(new Place(tokens[2],tokens[3],tok[0],tok[1],tok[tok.length-1]));
- }
- else
- {
- System.out.println("?");
- place.add(new Place(tokens[2],tok[0],tok[1],tok[tok.length-1]));
- }
- */
- }
- else
- {
- place.add(new Place(tokens[2],tokens[3],line));//tok[0],tok[1],tok[tok.length-1]));
- }
- /*
- * if(!this.city.contains(city))
- {
- this.city.add(city);
- }
- */
- }
- else if(tokens.length==5)
- {
- }
- line=br.readLine();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement