Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Help to parse text file

Reply
Thread Tools

Help to parse text file

 
 
kitty
Guest
Posts: n/a
 
      02-08-2006
Hi,
Iam new to perl and iam still reading up on regular exp and modules
(its something that can be extended for a long time ) !!
I want to build a parser/lexer (which is more appropriate ?) for a text
file which has a format similar to an xml file.

<GRAPH NAME="471138343152490055" VERSION="V3.0" APP_VERSION="2.7.2.8">
<NODE GUID="471138342839500090" TYPE="######"/>
<PROP GUID="471138342839500090" NAME="Unit" TYPE="Unit Conversion"
ATTRIBUTES="propagates editable !graphical visible !members !required "
SETON="1138343152541" SETBY="kitty" EXPR="On" />
<PROP GUID="471138342839500090" NAME="ODE Solver Settings" TYPE="ODE
Solver Settings" ATTRIBUTES="propagates editable !graphical visible
!members !required " SETON="1138343152549" SETBY="kitty" EXPR="&lt;E
Parameter_for_how_often_Jacobian_should_be_calcula ted=&quot;0.001&quot;
The_Rounding_Unit=&quot;1e-16&quot;
Absolute_Error_Tolerance=&quot;1e-15&quot;
Relative_Error_Tolerance=&quot;1e-7&quot; /&gt;" />
....
</GRAPH>

The output should list certain properties of a node..
NODE TYPE = "#######"
PROPERTIES :
NAME="Unit"
Value (EXPR) = "On"
NAME="ODE Solver Settings"
Value =
"Parameter_for_how_often_Jacobian_should_be_calcul ated=&quot;0.001&quot;
The_Rounding_Unit=&quot;1e-16&quot;
Absolute_Error_Tolerance=&quot;1e-15&quot;
Relative_Error_Tolerance=&quot;1e-7&quot; "
-------------------------------------------------------------------------------------------------
Also is it possible to change the value of the properties in the same
perl program after it is extracted using the parser/lexer ? I would
like to allow a user to see the above output for all the nodes in the
file , then modify the Value property (if needed).
If there is any modification i will rename the file along with the
modification time in the filename so the original file is left
untouched.
I have a feeling am going overboard with all these requests..but its
just an idea i had in mind which i want to implement.. I request you to
kindly help me out with your ideas and suggestions.
Thankyou all in advance .
Kitty

 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      02-09-2006
kitty <(E-Mail Removed)> wrote:


> for a text
> file which has a format similar to an xml file.



If it *is* an XML file, then use an XML parser instead of regexes.

It it is merely _similar_ to one, then we would need to know
it what ways it could differ.

A clear understanding of what data may appear is essential
to writing the code.


[ snip input and output data ]


> Also



Also?

You have not asked a question up to this point.

Did you mean to ask a question?

Is there something that you are stuck on?

What have you tried?


> I request you to
> kindly help me out with your ideas and suggestions.



Show us the code you have so far, and we will help you fix it.

Have you seen the Posting Guidelines that are posted here frequently?


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
 
kitty
Guest
Posts: n/a
 
      02-09-2006
Hi
Iam sorry for not posting my query in proper format..
i had put the "xmlish" code right below my intro..and i shall paste it
here again..also i had mentioned how i would like the output to be...

"xmlish" FILE
-------------------------------------------------------------------------------------------------------------------------------------
<GRAPH NAME="471138343152490055" VERSION="V3.0" APP_VERSION="2.7.2.8">
<NODE GUID="471138342839500090" TYPE="######"/>
<PROP GUID="471138342839500090" NAME="Unit" TYPE="Unit Conversion"
ATTRIBUTES="propagates editable !graphical visible !members !required "
SETON="1138343152541" SETBY="kitty" EXPR="On" />
<PROP GUID="471138342839500090" NAME="ODE Solver Settings" TYPE="ODE
Solver Settings" ATTRIBUTES="propagates editable !graphical visible
!members !required " SETON="1138343152549" SETBY="kitty" EXPR="&lt;E
Parameter_for_how_often_Jacobian_should_be_calcula ted=&quot;0.001&quot;
The_Rounding_Unit=&quot;1e-16&quot;
Absolute_Error_Tolerance=&quot;1e-15&quot;
Relative_Error_Tolerance=&quot;1e-7&quot; /&gt;" />
....
</GRAPH>
------------------------------------------------------------------------------------------------------------------------------

OUTPUT ( The output should list certain properties of a node..)
--------------------------------------------------------------------------------------------------------------------------------
NODE TYPE = "#######"
PROPERTIES :
NAME="Unit"
Value (EXPR) = "On"
NAME="ODE Solver Settings"
Value =
"Parameter_for_how_often_Jacobian_should_be_calcul ated=&quot;0.001&quot;
The_Rounding_Unit=&quot;1e-16&quot;
Absolute_Error_Tolerance=&quot;1e-15&quot;
Relative_Error_Tolerance=&quot;1e-7&quot; "
-----------------------------------------------------------------------------------------------------------------------

the "Also" was to continue the sentence after my request for the
output..
i shall post the code once am done reading the xml parsers suggested to
me and incorporating them in my code..i hope it would be easier to help
me out then since you will have a better idea about the problem..
thankyou and sorry for the inconvenience..

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
optparse: parse v. parse! ?? 7stud -- Ruby 3 02-20-2008 05:20 AM
How to parse a string like C program parse the command line string? linzhenhua1205@163.com C Programming 19 03-15-2005 07:41 PM
How to check for EOF (End of file) when using StreamReader to parse text file Sacha Korell ASP .Net 2 09-06-2003 02:59 PM
Parse Text File and Output to File John M. Lembo Perl Misc 2 08-01-2003 09:52 PM
Parse Text File and Output to File John M. Lembo Perl 0 08-01-2003 04:34 PM



Advertisments