Re: parsing a tree like structure



On Thu, Jun 26, 2008 at 9:57 AM, Pat Rice <patrick.j.rice@xxxxxxxxx> wrote:
Hi all
I'm wondering if there is a nice way to parse this data, as in is
there any module that could handle this type of data, as in the was it
is presented? so that I can repeat is itn a tree like structure in
HTML ?

so I can pic out the tree like structure and replicate it in some way
so that I can put it in an array or into a database ?? so i could pick
out the data I want.

\==+Interface :
|----Link State.........................................Down
\==+SCSI Interface :
|----Name............................................vmhba1
|----Console Name....................................scsi1
|----Queue Depth.....................................4096
\==+PCI Device :
|----Bus..........................................0x0b
|----Slot.........................................0x00
|----Function.....................................0x00
\==+Scsi Stats :
|----Commands.....................................48632378
|----Blocks Read..................................1862894689
|----Blocks Written...............................858120919
|----Aborts.......................................0

Thanks in advance
Pat

I'm thinking of representing each node as a hash of hashes... By
counting the number of leading spaces you can check if the level
changed. For lines starting ' +\|---' you add an element storing the
key/value and for lines starting with a \==+ you change the current
node to a new node.
Needs some work... This makes me think of my C course.
.



Relevant Pages

  • Re: Parsing and storing formulas
    ... you could easily store different views/stored ... >I was wondering how I can parse a mathematical formula in a storable way. ... > be stored for in the database. ... > The second idea is to represent the formula as a tree. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Parsing and storing formulas
    ... >I was wondering how I can parse a mathematical formula in a storable way. ... > be stored for in the database. ... > The second idea is to represent the formula as a tree. ... compiler/interpreter/expression evaluator does. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Fastening the run-time interpretation of mathematical expressions
    ... of stacks, one containig the operands and the other ... containig the operators. ... parse and analyse the source. ... parses the source to a tree, ...
    (comp.compilers)
  • Re: Storing data and code in a Db with LISP-like interface
    ... real, integers are perceptions. ... Take a tree. ... Your storytelling has zip to do with the idea of counting. ... And isn't that what the quoted post was describing? ...
    (comp.databases.theory)
  • FW: [Jython-users] ERROR : parsing xml in jython
    ... But I am unable to parse all the nodes of the tree .....especially the ... It displays only the sibling not the subtree ... I m facing the problem while parsing xml file .. ... """Parse XML document and show attributes and names. ...
    (comp.lang.python)