I am working on some code that will take a player name and their shooting percentage from a csvfile and put it into an object that I made called PlayerStat. I am trying to accomplish this by using CSVReaderHeaderAware.
Here is my code:
for (int i = 0; i < 100; i++){
Map<String, String> values = new CSVReaderHeaderAware(new FileReader("stats.csv")).readMap();
String playerName = values.get("Player Name");
double shootPct = Double.parseDouble(values.get("Percentage"));
PlayerStat stat = new PlayerStat(playerName, shootPct);
theArrayList.add(stat);
}
The first Map is fine and adds to the list perfectly. But, this code just keeps reading the first row of the csv file and I cannot figure out how to keep iterating through the rows in the csv file. Player Name and Percentage are the two columns I would like to go through. Thanks in advance!