java - Print specific lines(Words/numbers) from csv file -


lets have csv file this:

football contest blabla bla,,,,,,,  team number1,team number2,points team1,points team2,red cards  sweden,france,1,2,"  sweden,brazil,3,5,2  sweden,germany,2,2,3  sweden,spain,3,5," 

and in file want print out matches got red cards. in example print:
sweden - brazil = 2 sweden - germany = 3

this current code, , im stuck how move on.

try {     filereader fr = new filereader(file);     bufferedreader br = new bufferedreader(fr);      string lines = br.readline();     string result[] = lines.split(",");     do{         system.out.println();     }while((lines = br.readline()) != null);       //string result[] = lines.split(",");     //system.out.println(result[1]);      br.close();  }catch (filenotfoundexception e){     system.out.println("file not found : "+ file.tostring()); }catch (ioexception e ){     system.out.println("unable read file: "+ file.tostring()); } 

edit got helped with:

 while (line != null) {         string result[] = line.split(",");         if (result.length == 5) { //red cards present?             system.out.println(result[0] + " - " + result[1] + " " + result[4]);         }         line = br.readline(); //read next     } 

but problem have still prints because of " in csv file. why cant this?

    if (result[4] == "1,2,3,4,5" ){ system.out.println(result[0] + " - " + result[1] + " " + result[4]); } 

if index of red card , looks integer, see index integer or not if yes print 0,1 , 4 index[0]=team number1 index[1]=team number2 index[4]=red cards


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -