Solved

Interpret string as time

Posted on 2006-11-27
5
229 Views
Last Modified: 2010-04-30
I am currently writing a script that will copy data from a large file and parse it into usable data. What I need is a way to interpret the Duration string as a time and filter out all lines that have a duration shorter than 1 minute, 20 seconds. The sting looks like the following ( I already have a script that removes duplicate lines, so that doesn't need to be taken into account):

CurrentEvent:CutID=76866 Type=COM ArtistName=AGY/pg SongTitle=ORDWAY (2) Duration=00:00:58
Received: CurrentEvent:CutID=76866 Type=COM ArtistName=AGY/pg SongTitle=ORDWAY (2) Duration=00:00:58 (EventView)
CurrentEvent:CutID=LX014 Type=XMS ArtistName=Paul McCartney SongTitle=Wonderful Christmas Duration=00:03:42
Received: CurrentEvent:CutID=LX014 Type=XMS ArtistName=Paul McCartney SongTitle=Wonderful Christmas Duration=00:03:42 (EventView)
CurrentEvent:CutID=LXSW1 Type=XSW ArtistName= SongTitle=SWEEP-Generic Christmas Duration=00:00:13
Received: CurrentEvent:CutID=LXSW1 Type=XSW ArtistName= SongTitle=SWEEP-Generic Christmas Duration=00:00:13 (EventView)
CurrentEvent:CutID=LX326 Type=XMS ArtistName=Kenny Rogers/Dolly Parton SongTitle=A Christmas to Remember Duration=00:03:25
Received: CurrentEvent:CutID=LX326 Type=XMS ArtistName=Kenny Rogers/Dolly Parton SongTitle=A Christmas to Remember Duration=00:03:25 (EventView)
CurrentEvent:CutID=RTJX2 Type=XSW ArtistName= SongTitle=Talk Jin. :14 sec bed Duration=00:00:20
Received: CurrentEvent:CutID=RTJX2 Type=XSW ArtistName= SongTitle=Talk Jin. :14 sec bed Duration=00:00:20 (EventView)

Could someone please give me advice as to how to solve this dilemma?
0
Comment
Question by:joha0193
  • 2
  • 2
5 Comments
 
LVL 35

Expert Comment

by:Raynard7
ID: 18023245
Hi,

I'm not sure how you are reading your lines in but if for example you had a string representing the line ie strData you could do

strData = "Received: CurrentEvent:CutID=76866 Type=COM ArtistName=AGY/pg SongTitle=ORDWAY (2) Duration=00:00:58 (EventView)"
if cdate(left(split(a,"Duration=")(1), 8)) < #00:01:20# then
    'do not include this line
else
    'work with this line
end if

this assumes that each line will have a duration
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18023296
Are you already looping through the text, or do you need help with that also?

If you can get the data into a string variable, then something like this should work:

if cdate(mid(strData,instr(strData,"Duration=")+9)) > #12:01:20# Then
  'process string...
0
 

Author Comment

by:joha0193
ID: 18023366
I could use some help looping through the variable at this point. What I was trying didn't want to work with your answer, however I am very open to suggestions.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18023372
Can you post what you have now?
0
 

Author Comment

by:joha0193
ID: 18023419
Silly me, I just did some folder adjustments and forgot to change my script. Your stuff works great!! Thanks a ton.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question