looking for API to scan formated textfiles for specific information
<p>I have a a bunch of textfiles formated like this:</p>

<p>material Material.138_39BE7F6A_c.bmp.002 
{
    receive_shadows on </p>

<pre><code>technique
{
    pass Material.138_39BE7F6A_c.bmp.002
    {
        ambient 0.800000011920929 0.800000011920929 0.800000011920929 1.0
        diffuse 0.6400000190734865 0.6400000190734865 0.6400000190734865 1.0
        specular 0.5 0.5 0.5 1.0 12.5
        emissive 0.0 0.0 0.0 1.0

        alpha_to_coverage off
        colour_write on
        cull_hardware clockwise
        depth_check on
        depth_func less_equal
        depth_write on
        illumination_stage 
        light_clip_planes off
        light_scissor off
        lighting on
        normalise_normals off
        polygon_mode solid
        scene_blend one zero
        scene_blend_op add
        shading gouraud
        transparent_sorting on

        texture_unit 
        {
            texture 39BE7F6A_c.png
            tex_address_mode wrap
            scale 1.0 1.0
            colour_op modulate
        }
    }
}
</code></pre>

<p>}</p>

<p>And I need to convert them into a more modern format using a script, sort of like this:  </p>

<pre><code>material test{
    diffuse 0 1 0
    diffuse_map file:xxx.png
    glow 0 0 1
    etc...

}
</code></pre>

<p>Now I wonder, is there an API for Phyton or any other scripting language that would allow me to do this?   </p>

<pre><code>technique
</code></pre>

<p>{
    pass %title
    {
        ambient %ambient
        diffuse %diffuse
        specular %specualr
        emissive %emmissive</p>

<pre><code>    alpha_to_coverage off
    colour_write on
    cull_hardware clockwise
    depth_check on
    depth_func less_equal
    depth_write on
    illumination_stage 
    light_clip_planes off
    light_scissor off
    lighting on
    normalise_normals off
    polygon_mode solid
    scene_blend one zero
    scene_blend_op add
    shading gouraud
    transparent_sorting on

    texture_unit 
    {
        texture %texture
        tex_address_mode wrap
        scale 1.0 1.0
        colour_op modulate
    }
}
</code></pre>

<p>}</p>

<p>Bucause I have seen somethng like this before but I don't remember it exactly.<br>
So is there a tool or API that orks with a scripting language that lets me write templates for the scan to extract data from multiple files?</p>

<p>Since your input data actually has a <em>structure</em> and is constructed and can be parsed based on some <em>rules</em>. There are a number of parsers to choose from:</p>

<ul>
<li><a href="http://pyparsing.wikispaces.com/" rel="nofollow"><code>pyparsing</code></a></li>
<li><a href="http://www.dabeaz.com/ply/ply.html" rel="nofollow"><code>PLY</code></a></li>
<li><a href="https://github.com/vlasovskikh/funcparserlib" rel="nofollow"><code>funcparserlib</code></a></li>
</ul>

<p>They, of course, all have their differences and use cases they are more suitable for. Also see these great overviews and comparison tables:</p>

<ul>
<li><a href="https://github.com/webmaven/python-parsing-tools" rel="nofollow">A list of Python parsing tools</a></li>
<li><a href="http://nedbatchelder.com/text/python-parsers.html" rel="nofollow">Python parsing tools</a></li>
</ul>

python scanning data-extraction