MathGroup Archive 2006

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

Search the Archive

Re: data extraction question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63805] Re: data extraction question
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Sat, 14 Jan 2006 02:33:55 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 1/13/06 at 4:48 AM, martinro at carleton.edu wrote:

>I am working on a problem that requires I extract a certain part of
>a long, very messy test file.  It is part of a astrophysics special
>project, so I promise this isn't some homework question. It was
>written in IRAF and so uses placement of its charachters on the
>page to identify the meaning of the values.  I noticed that the
>data I wanted was essentially in ordered pair form, and that the
>only thing I had left on the line was a *\ symbol, and at the end
>of each group, was a *. My code to get thus far has been:

>data1=FindList["HAtemp.imh.ply.1","*"]
>In[6]:= Head[data1]
>Out[6]=List

This seems OK so far.

>In[7]:=merge[list_List]:= StringJoin[ Map[StringJoin[#,""]&,list] ]
>In[12]:=okay=merge[data1]
>In[9]:=Head[okay]
>Out[9]=String

Why do you want to convert the list of strings from FindList into a single single string?

I assume what you are interested in are the coordinate values and that it would be useful to have these as numeric quantities. If so, there is no need to combine the list of strings into a single string.

Given the file format you've indicated below,

ToExpression/@Most@StringSplit[#,RegularExpression@" +"]&/@data1

should do the what you want

>In[13]:=new=StringDrop[okay,1] 

>(This was because for some reason the first line was offset)

Given this you will need to treat the first string in the list separately, i.e.,

Join[
  {ToExpression/@StringSplit[StringDrop[First@data1,1],RegularExpression@" +"]},
  ToExpression/@Most@StringSplit[#,RegularExpression@" +"]&/@Rest@data1]

However, if you want to use your existing code and operate on your variable new

ToExpression/@StringSplit[#,RegularExpression@" +"]&/@
   StringSplit[StringReplace[new,"\\"->""],"*"]

will produce the same result as I've shown above.

And finally, if you want to keep the coordinates as strings rather than converting them to numeric values then simply omit the ToExprssion/@ in my solution.

--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Annoying spacing in Default.nb
  • Next by Date: Re: How to create {{x1,y1}, ..., {xn,yn}} data from {x1,...,xn} and {y1, ..., yn}
  • Previous by thread: Re: data extraction question
  • Next by thread: Re: data extraction question