6 Replies - 3482 Views - Last Post: 10 June 2011 - 03:08 PM Rate Topic: -----

#1 dsteve89   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 10-June 11

Reading files that contain scientific notation

Posted 10 June 2011 - 08:46 AM

What possible ways are there to read files that contain scientific notation and still it into an array? For example a data set such as:

2.34e4 4.73e5 8.83e4
5.82e5 9.12e3 7.37e6
etc....
Is This A Good Question/Topic? 0
  • +

Replies To: Reading files that contain scientific notation

#2 MATTtheSEAHAWK   User is offline

  • D.I.C Addict
  • member icon

Reputation: 137
  • View blog
  • Posts: 782
  • Joined: 11-September 10

Re: Reading files that contain scientific notation

Posted 10 June 2011 - 09:17 AM

Well if when you write it or whatever writes it puts a character in between each scientific notation number then you can just read to the end of the numbers and split at that character.

Right there it looks like every number has a space in between it so just split the contents into a string[] at that space. Then you can parse the data you get and use however you like.
Was This Post Helpful? 0
  • +
  • -

#3 kingfeanor   User is offline

  • D.I.C Head

Reputation: 47
  • View blog
  • Posts: 62
  • Joined: 18-April 09

Re: Reading files that contain scientific notation

Posted 10 June 2011 - 10:12 AM

Lookup the Javadoc for the StreamTokenizer class.
Was This Post Helpful? 0
  • +
  • -

#4 nick2price   User is offline

  • D.I.C Lover
  • member icon

Reputation: 565
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: Reading files that contain scientific notation

Posted 10 June 2011 - 11:21 AM

It being scientific notation doesnt matter. The way you have shown it, all you need to do is use a Tokenizer and use a space as a deliminator. This means it will split the words wherever there is a space.
Was This Post Helpful? 0
  • +
  • -

#5 dsteve89   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 10-June 11

Re: Reading files that contain scientific notation

Posted 10 June 2011 - 12:56 PM

Thanks to all, my program is working now.
Was This Post Helpful? 0
  • +
  • -

#6 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3744
  • View blog
  • Posts: 17,121
  • Joined: 20-September 08

Re: Reading files that contain scientific notation

Posted 10 June 2011 - 03:07 PM

Just use a Scanner and call nextDouble.
Was This Post Helpful? 0
  • +
  • -

#7 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3744
  • View blog
  • Posts: 17,121
  • Joined: 20-September 08

Re: Reading files that contain scientific notation

Posted 10 June 2011 - 03:08 PM

Just use a Scanner and call nextDouble.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1