Re: Time script help sought!

2005-01-11 Thread sp1d3rx
read below for my sample script

kpp9c wrote:
> I am kind of in a bit of a jam  (okay a big jam) and i was hoping
that
> someone here could give me a quick hand. I had a few pages of time
> calculations to do. So, i just started in on them typing them in my
> time calculator and writing them in by hand. Now i realize, that i
> really need a script to do this because:
>
> 1. It turns out there are hundreds of pages of this stuff.
> 2. I have to do something similar in again soon.
> 3. By doing it by hand i am introducing wonderful new errors!
> 4. It all has to be typed up anyway (which means weeks of work and
even
> more typos!)
>
> The input would like so:
>
> Item_1TAPE_1100:238:23
>
> Item_2TAPE_128:239:41
>
> Item_3TAPE_139:4110:41
> Item_3TAPE_1410:4711:19
> Item_3TAPE_1511:2111:55
> Item_3TAPE_1611:5812:10
> Item_3TAPE_1712:1512:45Defect in analog tape
sound.
> Item_3TAPE_1812:5824:20Defect in analog tape
sound.
>
> Item_4TAPE_1924:33
> Item_4TAPE_11025:48
> Item_4TAPE_11129:48
> Item_4TAPE_11231:46
> Item_4TAPE_11334:17Electronic sounds.
> Item_4TAPE_11435:21
> Item_4TAPE_11536:06
> Item_4TAPE_11637:0137:38
>
> These are analog tapes that were digitized (on to CD or a digital
tape)
> that have now been exported as individual files that are meant to be
> part of an on-line audio archive. The timings refer to the time
display
> on the CD or digital tape. The now all have to adjusted so that each
> item starts at 0.00 since they have all been edited out of their
> context and are now all individual items that start at 00:00. So
Item_1
> which was started at 00:23 on the tape and ended at 8:23 needs to
have
> 23 seconds subtracted to it so that it says:
>
> Item_1TAPE_1100:0008:00
>
> Item_2TAPE_1208:2309:41
>
> would change to:
>
> Item_2TAPE_1200:0001:18
>
> etc.
>
> but as always you may notice a wrinkle some items have many times
> (here 6) indicated:
>
> Item_3TAPE_139:4110:41
> Item_3TAPE_1410:4711:19
> Item_3TAPE_1511:2111:55
> Item_3TAPE_1611:5812:10
> Item_3TAPE_1712:1512:45Defect in analog tape
sound.
> Item_3TAPE_1812:5824:20Defect in analog tape
sound.
>
> This is all a single sound file and these separate times mark where
> there was a break, defect, or edit in the individual item. These have
> to be adjusted as well to show where these events would appear in the
> new sound file which now starts at 00:00.
>
> Item_3TAPE_1300:0001:00
> Item_3TAPE_1401:0001:38
> Item_3TAPE_1501:3802:14
> Item_3TAPE_1602:1402:29
> Item_3TAPE_1702:2903:04Defect in analog tape
sound.
> Item_3TAPE_1803:0414:39Defect in analog tape
sound.
>
> Further wrinkles: Some have start and end times indicated, some only
> start times. I suppose that the output would ideally have both
some
> have comments and others don't ... and I need these comments echo-ed
or
> since i probably need to make a database or table eventually non
> comments just have some place holder.
>
> I'd have a lot of similar type calculations to do... I was hoping and
> praying that some one here was feeling generous and show me the way
and
> then, of course i could modify that to do other tasks... Usually i am
> happy to take the long road and all but i'll be honest, i am in a big
> jam here and this huge task was just dumped on me. I am frankly a
> little desperate for help on this and hoping someone is feeling up to
> spoon feeding me a clear modifiable example that works. Sorry.
> cheers,
>
> kevin
START
inp = file("input1.txt",'r') # input file is opened readonly
x = inp.readline() #read in the first line of the file
x = x.upper().split(None,5) #convert it to uppercase and split into 5
segments
print x #show the line as splitted and converted
print x[1] #show the second element
start = x[3].split(":") #split the minutes from the seconds
end = x[4].split(":") #split the minutes from the seconds
print "Start at:", start[0], "minutes and ", start[1], "seconds."
start_in_seconds = int(start[0])*60 + int(start[1]) #converts
minutes/seconds to seconds
print start_in_seconds , "seconds offset."
print "End at:", end[0],"minutes and",end[1], "seconds."
end_in_seconds = int(end[0])*60 + int(end[1])#converts minutes/seconds
to seconds
print end_in_seconds , "seconds offset."
totaltime = end_in_seconds - start_in_seconds #calculate the length of
the segment
print "Total time of segment in seconds:", totaltime
print "Total time of segment in minutes/seconds:", totaltime/60,
"minutes and", totaltime % 60, "s

Re: Time script help sought!

2005-01-11 Thread sp1d3rx
Gosh Mark you must be a friggin genius or something. I can't even begin
to read your code. Anyways, I think mine is easier to understand. My
program has all the functions (save a couple) that you would need for
your project. It's an exercise for you to copy and paste what you want
where you want it and to form a basic program structure out of it. some
of my comments spilled on to the next line (thanks google!) so you will
have to clean it up a bit.

-- 
http://mail.python.org/mailman/listinfo/python-list