+ Reply to Thread
Results 1 to 3 of 3

How To Parse Specific text from String Data

  1. #1
    Registered User
    Join Date
    04-08-2011
    Location
    Jakarta,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    1

    How To Parse Specific text from String Data

    I have set of data in one column contain spesific code of meteorological element, but each data does not have same format, what i want to do is to get some text(data) by parsing from the code and put them in different column with certain category.

    Example :
    data: (in column A)
    1 METAR WARR 120000Z 29006KT 6000 HZ FEW020 25/24 Q1008 NSG=
    2 METAR WARR 120100Z 00000KT 7000 SCT020 25/24 Q1008=
    3 METAR WARR 120130Z 28004KT 240V300 8000 HZ NSC 27/24 Q1009=
    4 METAR WARR 121230Z 00000KT 7000 RA FEW020CB SCT020 24/23 Q1008=

    the result i expect :
    ____B______C______D______E______F______G_____H_____I______J____
    _direction_speed_Visibility_Weather_amount_height_temp_D.point_Pressure
    1__290_____06___6000_____HZ____FEW___2000___25____24_____1008
    2__000_____00___7000___________SCT____2000___25____24_____1008
    3__280_____04___8000_____HZ__________________27____24_____1009
    4__000_____00___7000_____RA____SCT____2000___24____23_____1008


    explaination for row 1:
    - Wind direction and speed get from : 29006KT (direction 290 , speed 06)
    - Visibility get from : 6000
    - Weather get from : HZ (row 2 weather is empty)
    - Cloud Amount & Height get from : FEW020 (amount FEW , height 20 => 2000) (row 3 cloud amount & height is empty)
    - Temperature & Dewpoint get from : 25/24 (temperature 25, D.point 24)
    - Pressure get from : Q1008

    Thanks for any help.
    Last edited by zaidan; 04-08-2011 at 04:26 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,286

    Re: How To Parse Specific text from String Data

    Some simpler extractions:

    =MID(A2,FIND("KT",A2)-5,3) direction
    =MID(A2,FIND("KT",A2)-2,2) speed
    =MID(A2,FIND("Q",A2)+1,4) pressure
    =MID(A2,FIND("/",A2)-2,2) temp
    =MID(A2,FIND("/",A2)+1,2) D.point

    These are all text values; if you need them to be numeric, use "=--MID(...)"

    For example

    =--MID(A2,FIND("KT",A2)-5,3) direction


    I can't help with some of the others because I don't know the layout or rules ... I have, for example, assumed that the direction and speed are presented together and terminated with "KT". Similarly, I assume that pressure is prefixed with a "Q".

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,286

    Re: How To Parse Specific text from String Data

    This might help to extract the weather:

    =IF(ISNUMBER(FIND("HZ",A2)),"HZ",IF(ISNUMBER(FIND("RA",A2)),"RA",""))

    However, it's not very scaleable, particularly if you have a lot of weather conditions to select from. There's probably a much better way but I can't think what it is right now.

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1