Map every second element of a list

Edit

Ok, so an incorrect answer producing arrays like:

{{"0.", RGBColor["0.00000000000", "0.00000000000", "0.00000000000"]}}

received +12 and an accept. Let's correct it though:

Activate @ ReadList[
  file
, {Number, RGBColor[Inactive[ToExpression][Word], Number, Number]}
, WordSeparators -> {"\t", " ", ","}
]
{{0., RGBColor[0., 0., 0.]}, ...}

Original answer

Let's try to get those numbers directly from the file:

ReadList[
  file
, {Word, RGBColor[Word, Word, Word]}
, WordSeparators -> {"\t", " ", ","}
]

To learn what is going on please read:

Can Read[] apply a custom function automatically to the read values?


If we define:

rgb[s_] := RGBColor @@ StringReplace[s, Whitespace~~n:NumberString :> ToExpression[n]]

then we can write any of the following expressions:

MapAt[rgb, Colors, {All, 2}]

Colors // Query[All, {2 -> rgb}]

ReplacePart[Colors, {i_, 2} :> rgb[Colors[[i, 2]]]]

to obtain:

result


Here is your list:

lst = {{0., " 0.00000000000 0.00000000000 0.00000000000"}, {11., 
   " 0.27843137255 0.41960784314 0.62745098039"}, {12., 
   " 0.81960784314 0.86666666667 0.97647058824"}, {21., 
   " 0.86666666667 0.78823529412 0.78823529412"}, {22., 
   " 0.84705882353 0.57647058824 0.50980392157"}};

Try this:

{#[[1]], RGBColor[Map[ToExpression, StringSplit[#[[2]]]]]} & /@ lst

(*  {{0., RGBColor[{0., 0., 0.}]}, {11., 
  RGBColor[{0.27843137255, 0.41960784314, 0.62745098039}]}, {12., 
  RGBColor[{0.81960784314, 0.86666666667, 0.97647058824}]}, {21., 
  RGBColor[{0.86666666667, 0.78823529412, 0.78823529412}]}, {22., 
  RGBColor[{0.84705882353, 0.57647058824, 0.50980392157}]}}   *)

enter image description here

Have fun!