Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: parsing a table

by hdb (Prior)
on Apr 15, 2013 at 12:38 UTC ( #1028731=note: print w/ replies, xml ) Need Help??


in reply to parsing a table

Looking at an .rtf file and the spec and the available modules, the situation seems difficult. RTF::tokenizer seems helpful to reduce the complexity a bit. I have created a sample rtf file using MS Word which contains one table only and the following script gets me most contents of the table (and some more). I do not dare say whether this helps in your situation.

use strict; use warnings; use RTF::Tokenizer; my $rtf = RTF::Tokenizer->new( file => "A.rtf" ); my( $t, $a, $p ); my $on = 0; while( $t ne "eof" ) { ( $t, $a, $p ) = $rtf->get_token(); print "TYPE|$t|ARGUMENT|$a|PARAMETER|$p|\n" if $on and $t eq "text"; + $on = 1 if $t eq "control" and $a eq "ltrrow"; $on = 0 if $a eq "control" and $a eq "row"; }


Comment on Re: parsing a table
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1028731]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-12-22 01:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (110 votes), past polls