Page 2 of 2 FirstFirst 12
Results 16 to 27 of 27
  1. #16
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

    You may get some ideas from this recent post.

    Does this string adocVER2_CAD: always precede the numeric value you are searching for? Is this the only place ":" appears? If so, then you can adapt Ajax's solution to get your numerics.

  2. #17
    DOSRoss is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2015
    Posts
    17
    Quote Originally Posted by orange View Post
    You may get some ideas from this recent post.

    Does this string adocVER2_CAD: always precede the numeric value you are searching for? Is this the only place ":" appears? If so, then you can adapt Ajax's solution to get your numerics.

    Reply:
    No ... it doesn't. The best way to get the data is ... Find the 'ms', see if there is a digit in front of it, then start the collecting of All digits in front of it. I don't see a consistent 'rule' to 'find and move forward' to collect the data.

  3. #18
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Can you run this query from the SQL backend directly? using substr and such?

  4. #19
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    ok

    we find ms, reverse the string prior to ms, which puts the number (if any) first, Val it to confirm it is a number, convert back to a string and reverse again


    strreverse(val(strreverse(left(myfield,instr(myfie ld,"ms ")-1))))

  5. #20
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Building on orange's post #5..................

    Quote Originally Posted by DOSRoss View Post
    <snip> There would be many lines in the log that have "ms" (i.e. 'msg') but not a number precede it.
    </snip>.
    Do the lines that have "ms" and a number preceding it always have "elapsed" after the "ms"?? Maybe need to look for "ms elapsed" instead of only "ms".


    I would use VBA to parse the text file (log) to another text file, then import the NEW text file. In this case, VBA can do a faster, better job parsing than trying to do everything in a query. (IMHO)

    VBA can also read a line, check for "elapsed", if not in string, move to next line....

    Quote Originally Posted by DOSRoss View Post
    My whole objective is to get the "Line Number" which will is separated when the txt file is imported and the "ms" number.
    Didn't see a line number is the provided example string (Post #1), but using VBA would be able to parse that also.....


    My $0.02...........

  6. #21
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    I think it would be helpful if DOSRoss showed a few more records so we can see exactly what he is facing.

  7. #22
    DOSRoss is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2015
    Posts
    17

    Extract number from String

    Quote Originally Posted by orange View Post
    I think it would be helpful if DOSRoss showed a few more records so we can see exactly what he is facing.
    The actual record would have ‘ID’ (line number), ‘DATE’, ‘Command’, ‘Time’. The examples below only show the 'Command' portion of the record.
    I would like to find the records that had numbers (digits) before (preceding) the ‘ms’ and extract the number, then put that number in that records ‘Time’ field. Then I could sort on the ‘Time’ field and get all the reporting that I need.

    Examples of lines that the time Would be collected …
    adocExecuteComplete| SQL Request exceeded reasonable time, adocVER2_CAD: 6627ms elapsed, type cmdText, status esOK, cursor ctUnspecified, lock ltReadOnly, records 1
    [GUI] TSpeedButton.Click(frmBrowActiveCalls.Panel3.btSpP ending)| Exiting: Elapsed time 609ms
    TfrmAvailableUnits.ThreadedRefresh| Disconnect Query: 11ms
    TfrmAvailableUnits.ThreadedRefresh| adsUnits Open: 14322ms
    ThreadedGlobalRefresh| Available Units Refresh: 280ms
    TfrmAvailableUnits.ThreadedRefresh| Refresh Clone[2]: 35ms
    TfrmBrowActiveCalls.ConnectQuery| Refresh Active Calls with 8 records and 8 grid rows: 14ms
    TfrmBrowActiveCalls.ConnectQuery| Refresh Edit Call: 1ms


    Examples of lines that would be ‘passed by’ the code …
    TFrmWatchDog.HandleKeyMessage| [GUI] Mouse Button: msg - hwnd = x
    TFrmWatchDog.ActiveFormChange| [GUI] Setting the active form to frmAvailableUnits_1($6281900):Clone EMS, FIR, RES Units Assigned
    Show_SYS| Check EMS Situation
    TfrmAvailableUnits.ThreadedRefresh| Entering for window Clone EMS, FIR, RES Units Assigned
    TDM.RMSSubjAlertsOnCall| Background thread is reading Alerts Cache object. Existing cache is being used for 15024709.
    adsActiveCallsAfterScroll| Call (15024709) Call_Status (A) categories () disp_zone (7670) esn (524) internal_esn (2700) actual_incid_city (MCMINNVILLE) run_zone_fire (101I) run_zone_ems (MEMS2) tract (322R)

  8. #23
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    what does 'passed' mean? I've revise my code having now seen some other examples

    Time: iif(instr([myfield],"ms")=0,0,val(strreverse(val(strreverse(left([myfield],iif(instr([myfield],"ms")=0,1,instr([myfield],"ms")-2)))))))

    this will return 0 if there is no 'ms' in the string or if there is it is not preceded with a number

  9. #24
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    one other thing - Date and Time are reserved words - using them can result in unexpected results

  10. #25
    DOSRoss is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2015
    Posts
    17
    Quote Originally Posted by Ajax View Post
    one other thing - Date and Time are reserved words - using them can result in unexpected results
    Everything is actually in TEXT except the ID - which is an Access generated number equaling the 'Line Number' of the Log that is being imported.
    So I haven't even begun to work with the Date issue ... only the digits representing a time value.

  11. #26
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    From the data examples in Post #22, I created a text file.
    Then I created a Parse example dB.
    This demo extracts the Elapsed time from the text file.

    Both files are in the attached Zip.

    The OP also wants to get the line number and the date/time. These could be easily added to the parse code.......


    Good luck with your project......

  12. #27
    DOSRoss is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2015
    Posts
    17
    Quote Originally Posted by ssanfu View Post
    From the data examples in Post #22, I created a text file.
    Then I created a Parse example dB.
    This demo extracts the Elapsed time from the text file.

    Both files are in the attached Zip.

    The OP also wants to get the line number and the date/time. These could be easily added to the parse code.......


    Good luck with your project......

    Thank you very Much.
    I have learned a great deal from all the input of this Forum.
    I very much appreciate all the time each of you have invested.

    Thank you,

    Ross

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Extract part of string
    By Fais in forum Access
    Replies: 5
    Last Post: 08-06-2014, 04:46 PM
  2. Extract a number from a string
    By webisti in forum Access
    Replies: 3
    Last Post: 09-16-2013, 08:29 AM
  3. Extract Value from Variable in String
    By nguyenak in forum Programming
    Replies: 3
    Last Post: 05-24-2012, 03:50 PM
  4. Extract String From Between 2 Values
    By kathleencampbell in forum Queries
    Replies: 5
    Last Post: 03-23-2012, 10:52 AM
  5. Convert Number to String in .csv extract
    By CindyR19 in forum Import/Export Data
    Replies: 3
    Last Post: 08-17-2011, 02:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums