I'm a beginner at Python trying to write my first script. I've got a text file with multiple lines and need to eventually extract a piece of timecode from the list. The list looks like this:
010 AX V C 01:01:26:10 01:01:27:17 01:00:08:19 01:00:10:02
* FROM CLIP NAME: movie1.mov
011 AX V C 01:01:30:19 01:01:32:19 01:00:10:02 01:00:12:02
* FROM CLIP NAME: movie2.mov
012 AX V C 01:00:15:01 01:00:17:13 01:00:12:02 01:00:14:14
* FROM CLIP NAME: movie3.mov
etc.
My first objective is to grab the first timecode displayed.
I know that the first timecode on every line starts at character #29 and ends at character #40 so I started by trying to remove the first 29 characters but anytime it prints it's not starting at the right character.
timecode = [] # Declaring my empty list.
with open ('test.edl', 'rt') as myfile: # Opening the edl.
for myline in myfile: # For each line in the file,
print(myline.lstrip(myline[:29])) # strip first 29 chars
Rather than stripping the first 29 chars, I'm receiving this in return:
:01:26:10 01:01:27:17 01:00:08:19 01:00:10:02
movie1.mov
:01:30:19 01:01:32:19 01:00:10:02 01:00:12:02
movie2.mov
:00:15:01 01:00:17:13 01:00:12:02 01:00:14:14
movie3.mov
Even when I change print(myline.lstrip(myline[:29]))
to [:25]
, it prints the lines the same way.
When I'm using [:20]
it's giving me a better result but it's still incorrect.
C 01:00:15:01 01:00:17:13 01:00:12:02 01:00:14:14
I've been searching relentlessly to figure out what I'm doing wrong here but no luck.. Again, complete beginner here so I'm sorry if this is plain stupidity.
Thank you very much!