Building several parsing modules

Discussion in 'Python' started by Robert Neville, Mar 18, 2007.

  1. Basically, I want to create a table in html, xml, or xslt; with any
    number of regular expressions; a script (Perl or Python) which reads
    each table row (regex and replacement); and performs the replacement
    on any file name, folder, or text file (e.g. css, php, html). For
    example, I often rename my mp3 (files); the folder holding the mp3
    files; and replace these renamed values in a playlist/m3u/xml file.

    The table should hold clean regular expressions with minimal escaping.
    The regular expressions would incorporate multiple lines and complex
    expressions (e.i. symbolic grouping, back referencing, negative
    lookahead). The table would serve as a preset file for any replacement
    task. It also contains short description column for each regular
    expression. The table could contain 1 to 1000 regular expressions; and
    the input file could have 1000 to ten thousand lines as well. SED
    would become messy here.

    I am just starting out with building the logic and pseudo-code. I am
    hoping for any examples where these libraries have been applied. Links
    and guides would help since I am just starting out with the language.
    I need suggestions and examples on reading input by line; managing
    large data sets; iterating through an xml/html structure; and various
    parsing techniques.

    I built a solution in VBScript and VBA, but it had several limitations
    like operating on one platform and did not have full Perl regular
    expression support. In addition, it is attached to an Access database.
    The solution would parse and add headers to the data. It would parse
    the data with the headers and insert it into a table. It had over
    fifteen modules for repetitive parsing tasks to build a importable
    data set. VBScript Regexes are not as powerful as Perl or even sed.

    This request is large, yet someone with command of the language could
    give guidance on the basic framework to kickstart my efforts.
    Basically, I need someone to say start here; then proceed to this
    function; then look into these libraries; so on.
     
    Robert Neville, Mar 18, 2007
    #1
    1. Advertising

  2. Robert Neville wrote:

    > Basically, I want to create a table in html, xml, or xslt; with any
    > number of regular expressions; a script (Perl or Python) which reads
    > each table row (regex and replacement); and performs the replacement
    > on any file name, folder, or text file (e.g. css, php, html). For
    > example, I often rename my mp3 (files); the folder holding the mp3
    > files; and replace these renamed values in a playlist/m3u/xml file.


    <snip/>

    Don't do it. Just write python for the task at hand - if it involves regular
    expressions, use the re module if you must, but lots of stuff can be done
    with simpler, less confusing means like string.split and the like.

    The result should be a small few-liner. You are way better off with that,
    especially when you have to take constraints into account like moon phase
    or the like - you then have the full power of python at your hand, instead
    of inventing some wicked table-based "language" that you code exceptions
    into.

    Diez
     
    Diez B. Roggisch, Mar 19, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fuming Wang
    Replies:
    7
    Views:
    346
    =?iso-8859-1?q?Fran=E7ois_Pinard?=
    Jul 17, 2003
  2. Thomas Weholt
    Replies:
    0
    Views:
    263
    Thomas Weholt
    Jan 15, 2004
  3. Shannon Cayze

    Several issues with building a user control

    Shannon Cayze, Jun 30, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    146
    ctmhz
    Jul 5, 2003
  4. Victor \Zverok\ Shepelev

    RDOC: several related modules in several C files

    Victor \Zverok\ Shepelev, Mar 6, 2007, in forum: Ruby
    Replies:
    3
    Views:
    200
    Max Lapshin
    Mar 16, 2007
  5. kz
    Replies:
    0
    Views:
    142
Loading...

Share This Page