+ Reply to Thread
Results 1 to 3 of 3

How to get only specific information from a txt file(Advanced-updated)

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-27-2010
    Location
    singapore
    MS-Off Ver
    Excel 2003
    Posts
    107

    How to get only specific information from a txt file(Advanced-updated)

    For this thread I would like to know once I opened a txt file instead of opening the entire contents from the file, I would like my macro to

    1) Look for “Sub Pre_Shorts” and “subend”. “Sub Pre_Shorts” is the starting point and “subend” is ending point. I need to extract information data that are between these two points (I managed to do this, take a look at my attached file)

    Once locate these two points, need to do the following steps:

    2) Look for lines that start with “!”, if the next word is something like, test "analog/….” Or test "Digital/….” Get their information onto the spreadsheet. For e.g. if the line is

    !#@ test "analog/l1" on boards BoardSet_boards_1_to_2(*)

    - “!” should be column A, “#@” not needed
    - “analog” in column B
    - “l1” in column C
    - The rest of the words in the line not needed

    3) Look for lines that start with “test”, if the next word is something like, "analog/….” Or "Digital/….” Get their information onto the spreadsheet. For e.g. if the line is

    test "digital/u3" on boards BoardSet_boards_1_to_2(*) !ok

    - “Digital” in column B
    - “u3” in column C
    - The rest of the words in the line not needed

    This is only extracting data for Sub Pre_Shorts. There is still few other “Sub …. “. So once the macro complete the task for “Sub Pre_Shorts”. It should look for the other “Sub …” and repeat step 2 and 3. Below is the name of the other “Sub .. “ names which need to look for,

    Start Point
    End Point

    Sub Analog_Tests
    subend
    sub BScan_Powered_Shorts_Tests
    subend
    sub BScan_Interconnect_Tests
    subend
    sub BScan_Incircuit_Tests
    subend
    sub BScan_Silicon_Nails_Tests
    subend
    sub Digital_Tests
    subend
    sub Functional_Tests
    subend
    sub Analog_Functional_Tests
    subend

    Inside the txt file (attached) there is other names starting with “Sub..", e.g. “sub Connect_Check” those are not needed to extract, so can ignore.

    Important: If one of the start point cannot be found in the txt file, the macro should ignore that start point and should continue with the other start points, (e.g. if “Sub Analog_Tests” is not in the txt file, just ignore it and continue with the rest of the start points).

    Right now, I am stuck at step 2 and 3, and also not sure how to loop so that once it complete one start point it goes on with another start point.
    I have attached some pictures to illustrate more clearly.
    sub.jpg
    sub2.jpg
    spec.jpg

    i have attached sample txt file
    I have also attached a workbook, Sheet1 consist a button with my codes and sheet2 is what I desired output should look like
    Extract.xls
    testplan_mario.zip
    Last edited by darkhorse4321; 11-06-2010 at 12:39 AM.

  2. #2
    Forum Contributor
    Join Date
    10-27-2010
    Location
    singapore
    MS-Off Ver
    Excel 2003
    Posts
    107

    Re: How to get only specific information from a txt file(Advanced-updated)

    hi,i forgot to attach sample .txt file,i have attached them in zip file.

  3. #3
    Forum Contributor
    Join Date
    10-27-2010
    Location
    singapore
    MS-Off Ver
    Excel 2003
    Posts
    107

    Re: How to get only specific information from a txt file(Advanced-updated)

    Hi, does anyone know how to solve this problem?
    Last edited by darkhorse4321; 11-06-2010 at 09:58 AM.

+ 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