Message Boards Message Boards

0
|
6114 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Converting '2.345e-17' strings into numbers while importing a CSV file?

Posted 11 years ago
Hi all,

suppose we have a list of number pairs like this (first 11 lines of a .txt file):
 0,3E-14
 0.001,-7E-14
 0.002,-4E-14
 0.003,2.9E-13
 0.004,3.1000000000000004E-13
 0.005,1.2E-13
 0.006,2.3E-13
 0.007,-7E-14
 0.008,1.1000000000000001E-13
0.0090000000000000011,1E-14
0.01,4E-14

Response:
{{"0,3E-14"}, {"0.001,-7E-14"}, {"0.002,-4E-14"}, {"0.003,2.9E-13"}, \
{"0.004,3.1000000000000004E-13"}, {"0.005,1.2E-13"}, \
{"0.006,2.3E-13"}, {"0.007,-7E-14"}, \
{"0.008,1.1000000000000001E-13"}, {"0.0090000000000000011,1E-14"}, \
{"0.01,4E-14"}, ... }

Now I imported this into a table:
values = Import["data.txt", "Table"]

And tried to plot it like this:
ListPlot[values]

Unfortunately, the result was only this:


Now I suspect that Mathematica (version 8, btw) didn't understand the number format of the second number of the pairs (like "4E-14").
Could that be the case? If so: how can these types of numbers be converted into "real" numbers Mathematica understands?

Or do we have another problem here?

Thanks so much!
Stefan.
POSTED BY: Stefan Wolfrum
2 Replies
Awesome! Thanks so much! emoticon
POSTED BY: Stefan Wolfrum
Try:
data = Import["data.txt", "CSV"]
and then look at your input data usingĀ InputForm
data // InputForm
It looks better - no quotes:
{{0, 3.*^-14}, {0.001, -7.*^-14}, {0.002, -4.*^-14}, {0.003, 2.9*^-13},
{0.004, 3.1000000000000004*^-13}, {0.005, 1.2*^-13}, {0.006, 2.3*^-13},
{0.007, -7.*^-14}, {0.008, 1.1000000000000001*^-13},
{0.009000000000000001, 1.*^-14}, {0.01, 4.*^-14}}
and plots OK too.
ListPlot[data, Joined -> True]
POSTED BY: C ormullion
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract