0

My problem is to parse value from CSV to double. I can't understand why I can parse all values from columns A-BJ and when I have column BK java throw error

Exception in thread "main" java.lang.NumberFormatException: For input string: "4,69E+12" at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source) at sun.misc.FloatingDecimal.parseDouble(Unknown Source) at java.lang.Double.parseDouble(Unknown Source) at Compare.normalizacja_dziesietna(Compare.java:68) at Compare.main(Compare.java:138) 

For example in columnt BE there is also o big number and there is no problem with parsing...

Here there is a screenshot of the file https://pasteboard.co/HVkMt4L.png

2
  • Can you show us the java code? Commented Jan 7, 2019 at 11:36
  • It's treating the value as a String so you're trying to parse "4,96E+12" as a Double which isn't valid. Make sure the column is formatted as a number and check the value of the raw CSV file in a text editor. Commented Jan 7, 2019 at 11:38

2 Answers 2

1

Double.parseDouble expects 4.69E+12 instead of 4,69E+12.

Example:

Double.parseDouble("4,69E+12".replaceAll(",", "\\.")); 
Sign up to request clarification or add additional context in comments.

Comments

0

You should use BigDecimal instead.

Read more here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.