我有一个XML跟踪文件,该文件的大小约为350MB。当我使用下面的代码时,一次它产生内存满问题,另一次它产生关于无法解析文件的错误。我应该如何解析这个巨大的文件?是否使用不同的方法进行解析
root = ET.parse('E:/software/jm_16.1/bin/tracefile.xml').getroot()
lst = root.findall('AVCTrace/Picture/SubPicture/Slice/MacroBlock')
for item in lst:
print (item.get('QP_Y'))
I also produce a smaller file and based on the above file and the variable `lst` is empty!!. do you know what is the problem?
my XML trace file is as follows:
I also need to extract X tag and Y tag in Macroblock. for this I used <MacroBlock num="8158">
<SubMacroBlock num="0">
<Type>1</Type>
<TypeString>B_L0_8x8</TypeString>
<MotionVector list="0">
<RefIdx>0</RefIdx>
<Difference>
<X>-1</X>
<Y>-2</Y>
</Difference>
<Absolute>
<X>-4</X>
<Y>-6</Y>
</Absolute>
</MotionVector>
</SubMacroBlock>
树的根已经是
Picture
,因此不应在其中搜索Picture/...
。通过将名为
QP_Y
的节点添加到搜索路径,可以直接搜索所有节点如果您更喜欢在宏块上迭代,并使其QP_Y:
相关问题 更多 >
编程相关推荐