Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Part or Partition or Split or Extract or ...... ????

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85418] Re: Part or Partition or Split or Extract or ...... ????
  • From: Bill Rowe <readnewsciv at sbcglobal.net>
  • Date: Sun, 10 Feb 2008 05:11:37 -0500 (EST)

On 2/9/08 at 4:20 AM, xrayspectrum at googlemail.com (Mayneord) wrote:

>Hallo All,
>
>Please have a look at my code. Here I am trying to get only the
>value 25\55 in the Out[3] and  0\60 in the Out[4] without text and
>other intergers and I would like to separate them into different
>columns like   25   55  0  60   and similarly I wanted to separate
>the values
>64.5\64.5\64.5\64.5\64.5\64.5\64.5\64.5\64.5\64.5\64.5\64.5\64.5\6..
>. in the Out[5] into one column.

>[In]1:=   A = Import["new3.txt", "CSV"];

>In[2]:=Length[Import["new3.txt","CSV"]] Out[2]= 402

>In[3]:=  A[[1]] Out[3]= {(300a,011c) DS
>[25\55]                     #   6, 2 \            unknownparameter}

>In[4]:=  A[[2]] Out[4]=  {(300a,011c) DS
>[0\60]                     #   4, 2 \            unknownparameter}

>In[5]:=  A[[3]] Out[5]= {(300a,011c) DS
>[64.5\64.5\64.5\64.5\64.5\64.5\64.5\64.5\64.5\64.5\64.5\64.5\
>\64.5\6... # 400,80 unknownparameter}

>My goal is to substract 55 from 25 in the Out[3] and 0 from 60.
>Finally, extract the 80 values from the Out[5] then subtract
>1,2,3....40 value from 41,42,42.....80 value.

It looks like the things you are working with are strings and
the portion of the string you are interested in lies between a
'[' character and ']' character. Further, the numbers you are
interested in seem to be separated by '/' characters. If I have
this write, what you want to achieve can be done as follows:

First, to get rid of the string parts of no interest

StringReplace[dataString, {RegularExpression@"^.+\["->"",RegularExpression@=
"\[.+$"->""}]

The result will be just the portion of the string between the
'[' character and ']' character. This assumes the characters '['
and ']' only occur once.

Now that you have just the string of numbers separated with '/'
characters you can use StringSplit to create a list of these
numbers as strings. That is

StringSplit[stringPart,"/"]

where stringPart is the portion of the original string that has
the numbers of interest.

Finally, the resulting list of strings can be converted to
numbers by mapping ToExpression to each of the strings.

--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Resolve[Exists[i,{-1,0,2,-3,4,0}>0],Integers] does not work
  • Next by Date: Re: Part or Partition or Split or Extract or ...... ????
  • Previous by thread: Part or Partition or Split or Extract or ...... ????
  • Next by thread: Creating notebook templates