private List<Location> readLocationCSV(File filename) throws IOException { CsvReader reader = new CsvReader(filename.getAbsolutePath(), ',', Charset.forName("UTF8")); reader.setTextQualifier('"'); reader.skipLine(); reader.readHeaders(); ArrayList<Location> locations = new ArrayList<Location>(); while (reader.readRecord()) { double lat = Double.parseDouble(reader.get("latitude")); double lon = Double.parseDouble(reader.get("longitude")); String country = reader.get("country"); Location location = new Location(); location.latitude = lat; location.longitude = lon; location.country = country; locations.add(location); } return locations; }
private List<Block> readBlocksCSV(File filename) throws IOException { CsvReader reader = new CsvReader(filename.getAbsolutePath(), ',', Charset.forName("UTF8")); reader.setTextQualifier('"'); reader.skipLine(); reader.readHeaders(); ArrayList<Block> blocks = new ArrayList<Block>(); while (reader.readRecord()) { int startIp = Integer.parseInt(reader.get("startIpNum")); int endIp = Integer.parseInt(reader.get("endIpNum")); int pixelId = Integer.parseInt(reader.get("pixelId")); Block block = new Block(); block.startIp = startIp; block.endIp = endIp; block.pixelId = pixelId; blocks.add(block); } return blocks; }