Message Boards Message Boards

0
|
2884 Views
|
4 Replies
|
1 Total Likes
View groups...
Share
Share this post:
GROUPS:

ToExpression and decimal separators?

Posted 11 years ago
i'm  a little confused a puzzled when it comes to the following : list  {{"1,78 ", 323}, {"1,78 ", 3371}, {"1,77 ", 20}, {"1,79 ",
  10}, {"1,77 ", 400}, {"1,78 ", 600}, {"1,77 ", 1140}, {"1,77 ",
  90}, {"1,77 ", 10}, {"1,75 ", 50}, {"1,77 ", 1900}, {"1,77 ",
  1490}, {"1,77 ", 10}, {"1,75 ", 3407}, {"1,74 ", 1500}, {"1,74 ",
  4500}, {"1,74 ", 323}, {"1,75 ", 3000}, {"1,75 ", 3623}, {"1,75 ",
  1377}, {"1,75 ", 1000}, {"1,75 ", 800},....}
 For example :Map[Head, Take[%, {15}], {2}] and its out :{{String, Integer}} . Why I can not convert string for real when using ToExpression ?
POSTED BY: Artur Kotarski
4 Replies
Posted 11 years ago
Thank You for steering me  towards right direction.
POSTED BY: Artur Kotarski
 Oh, I see, it is complaining about the decimal separator. Perhaps something like ToExpression[MapAt[StringReplace[#, "," -> "."] &, list, {All, 1}]] ?
POSTED BY: Ilian Gachevski
Posted 11 years ago
pomitr2 = N[ToExpression[list[[All, {1}]]]] out ---ToExpression::sntx: Invalid syntax in or before "1,78 ". I want all fractions to be recognised as numbers for further
calculations .
                                                  
POSTED BY: Artur Kotarski
Are you looking for something like N[ToExpression["123"]]?
POSTED BY: Ilian Gachevski
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