Mercurial > dive4elements > river
changeset 5922:8ed9b1edace6
issue1267: W80CSVParser do not stumble about malformed lines.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 08 May 2013 11:42:08 +0200 |
parents | 17b07104d093 |
children | 131f5f58ff7d |
files | backend/src/main/java/org/dive4elements/river/importer/parsers/W80CSVParser.java |
diffstat | 1 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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)) {