寻找API来扫描格式化文本文件以获取特定信息

时间:2016-10-13 15:56:18

标签: python scanning data-extraction

我有一堆像这样形成的文本文件:

材料Material.138_39BE7F6A_c.bmp.002 {     

上的receive_shadows
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
        }
    }
}

}

我需要使用脚本将它们转换为更现代的格式,如下所示:

material test{
    diffuse 0 1 0
    diffuse_map file:xxx.png
    glow 0 0 1
    etc...

}

现在我想知道,Phyton或任何其他脚本语言的API是否允许我这样做?

technique

{     传递%标题     {         环境%环境         漫反射%弥漫         镜面%specualr         发光%emmissive

    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
    }
}

}

因为我之前见过这样的事情,但我不记得确切 那么是否有一个工具或API与脚本语言一起使用,可以让我编写扫描模板以从多个文件中提取数据?

1 个答案:

答案 0 :(得分:1)

由于您的输入数据实际上具有结构并且已构建,因此可以根据某些规则进行解析。有许多解析器可供选择:

当然,他们都有自己的差异和更适合的用例。另请参阅这些精彩的概述和比较表:

相关问题