# HG changeset patch # User Felix Wolfsteller # Date 1368006128 -7200 # Node ID 8ed9b1edace62f2ca2d841890edf77d48fcb8f22 # Parent 17b07104d0931e4c5740681c248fb58ce0774edd issue1267: W80CSVParser do not stumble about malformed lines. diff -r 17b07104d093 -r 8ed9b1edace6 backend/src/main/java/org/dive4elements/river/importer/parsers/W80CSVParser.java --- a/backend/src/main/java/org/dive4elements/river/importer/parsers/W80CSVParser.java Wed May 08 10:37:25 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/W80CSVParser.java Wed May 08 11:42:08 2013 +0200 @@ -250,10 +250,21 @@ String dateH = line.substring(54,60); String dateDec = line.substring(64,70); - double stationKm = Double.parseDouble(station) / 1000d; - double gkRightKm = Double.parseDouble(gkRight.replace(",","."));//.substring(0,7)); - double gkHighKm = Double.parseDouble(gkHigh.replace(",","."));//.substring(0,7)); - double heightM = Double.parseDouble(height.replace(",",".")); + double stationKm; + double gkRightKm; + double gkHighKm; + double heightM; + + try { + stationKm = Double.parseDouble(station) / 1000d; + gkRightKm = Double.parseDouble(gkRight.replace(",","."));//.substring(0,7)); + gkHighKm = Double.parseDouble(gkHigh.replace(",","."));//.substring(0,7)); + heightM = Double.parseDouble(height.replace(",",".")); + } + catch (java.lang.NumberFormatException nfe) { + logger.error("Skipping malformed w80csv line #" + lineNum); + return; + } // New (or first) line. if (anchor == null || !anchor.sameStation(stationKm)) {