Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

parsing a strig

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119832] parsing a strig
  • From: Ted Sariyski <tsariysk at craft-tech.com>
  • Date: Fri, 24 Jun 2011 07:47:16 -0400 (EDT)
  • References: <201106231125.HAA25913@smc.vnet.net>

Hi,
I import a text file with Import[filename,"Table"]. The file has a 
header followed by data. The header contains predefined keywords like 
TITLE, ZONE, VARIABLES, etc.  A VARIABLES line, shown below, is a list 
of 'varname,varunits' pairs, which I need to extract as pairs.

{{VARIABLES,=,'um','I_p,(W/sr/um)','I_a,(W/sr/um)','I_ae,(W/sr/um)','m','I_p,(W/sr/m)','I_a,(W/sr/m)','I_ae,(W/sr/m)'}}

I tried StringSplit[varList,"'"] but got
Out[]:  {{um,,,I_p},{(W/sr/um),,,I_a},{(W/sr/um),,,I_ae},...}}, which is 
wrong.

I tried StringSplit[Drop[vars, 2], "'"] and got
Out[]: {{I_a (W/sr/um)},{I_ae (W/sr/um)},...}}, which miss the first 
variable 'um'.

How can I parse this?
Thanks in advance,
--Ted


  • Prev by Date: Re: Export a Grid[] object without loosing it's format
  • Next by Date: Re: pattern example
  • Previous by thread: Automatic Equation Numbering when "save as"Latex
  • Next by thread: DSolve gives different answer to NDSolve