private void parseRoutes(BufferedReader reader) throws IOException { HashSet<String> blacklist = getBlackList(); // route_id,agency_id,route_short_name,route_long_name,route_desc,route_type,route_color,route_text_color Pattern pattern = Pattern.compile( "^([^,]+),[^,]*,(?:\"([^\"]+)\"|([^,]+)),(?:\"[^\"]*\"|[^,]*),(?:\"[^\"]*\"|[^,]*),[^,]*,([0-9a-fA-F]{6}),([0-9a-fA-F]{6})"); String line = reader.readLine(); // skip column names while ((line = reader.readLine()) != null) { Matcher matcher = pattern.matcher(line); if (!matcher.matches()) { write(line); continue; } String unquotedShortName = matcher.group(3); String shortName = unquotedShortName != null ? unquotedShortName : matcher.group(2); if (!blacklist.contains(shortName)) { Route route = new Route(); route.setShortName(shortName); route.setColor(matcher.group(5)); route.setTextColor(matcher.group(4)); route.persist(); routes.put(matcher.group(1), route.getId()); } } }