[Pyparsing] Newbie question - conditional parsing/actions
Brought to you by:
ptmcg
From: Robin S. <rob...@ds...> - 2015-04-20 00:29:48
|
I am new to this and I am having trouble figuring out how to parse the below text. Much of the data in the 2 blocks below are similar. There is one crucial keyword that will differentiate the 2 blocks: the 1st line will either contain "vide (Video)" or "soun (Audio)". I can't figure out how to determine which one is present in the first line and then how to say 'If it is "vide" do this, otherwise do that'. Track ID 1 vide (Video) Enabled Self-contained Format vide/avc1 dimensions: video 1920 x 1080, presentation: 1920 x 1080 (pixelAspect+clean), cleanAperture: 1920 x 1080 @ 0,0 (originTopLeft) Media Timescale: 600 Duration: 14076/600 00:00:23.460 MinSampleDuration: 10/600 AdvanceDecodeDelta: 0/600 00:00:00.000 Num data bytes: 91412686 Est. data rate: 31.172 Mbps Nominal framerate: 59.974 fps 1407 samples Included in auto selection. Language code<und> Dimensions: 1920 x 1080 CleanAperture: 1920 x 1080 ProductionAperture: 1920 x 1080 EncodedPixels: 1920 x 1080 Track Matrix: 0.0 1.0 0.0 / -1.0 0.0 0.0 / 1080.0 0.0 1.0 1 edit: Media start 0/600 00:00:00.000 dur 14076/600 00:00:23.460 Track start 0/600 00:00:00.000 dur 14076/600 00:00:23.460 Track ID 2 soun (Audio) Enabled Self-contained Format soun/aac 44100 Hz aac FormatFlags: 0x00000000 Bytes/Pkt: 0 Frames/Pkt: 1024 Bytes/Frame: 0 Chan/Frame: 1 Bits/Chan: 0 Reserved: 0x00000000 ChannelLayout: Mono Media Timescale: 44100 Duration: 1037312/44100 00:00:23.522 MinSampleDuration: 1024/44100 AdvanceDecodeDelta: 0/44100 00:00:00.000 Num data bytes: 184508 Est. data rate: 62.753 kbps Nominal framerate: 43.066 fps 1013 samples Track volume: 1 Included in auto selection. Language code<und> Dimensions: 0 x 0 Track Matrix: 1.0 0.0 0.0 / 0.0 1.0 0.0 / 0.0 0.0 1.0 1 edit: Media start 0/44100 00:00:00.000 dur 14076/600 00:00:23.460 Track start 0/600 00:00:00.000 dur 14076/600 00:00:23.460 -- Sent with Postbox <http://www.getpostbox.com> |