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....
Reading files that contain scientific notation
Page 1 of 16 Replies - 3482 Views - Last Post: 10 June 2011 - 03:08 PM
Replies To: Reading files that contain scientific notation
#2
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.
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.
#3
Re: Reading files that contain scientific notation
Posted 10 June 2011 - 10:12 AM
Lookup the Javadoc for the StreamTokenizer class.
#4
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.
#5
Re: Reading files that contain scientific notation
Posted 10 June 2011 - 12:56 PM
Thanks to all, my program is working now.
#6
Re: Reading files that contain scientific notation
Posted 10 June 2011 - 03:07 PM
Just use a Scanner and call nextDouble.
#7
Re: Reading files that contain scientific notation
Posted 10 June 2011 - 03:08 PM
Just use a Scanner and call nextDouble.
Page 1 of 1

New Topic/Question
Reply


MultiQuote





|