Consulting

Results 1 to 5 of 5

Thread: How do i extract a part of text file content

  1. #1
    VBAX Newbie
    Joined
    Dec 2017
    Posts
    3
    Location

    How do i extract a part of text file content

    Hi,
    I am just learning VB. I need to know how can i extract specified record from text file1 having many records as data and save the extracted data in another text file2.Text file1 data is something like

    type Z is

    record
    ***

    end record

    type Y is

    record
    ***

    end record

    and some n of records are in this text file1

    I want to have only specified records like extract only Z , Y records of X , Y , Z records from text file1

    I think i am clear with question. Can someone help with this??

    Thanks in advance.

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    A sample text file would help a lot.
    If you can indicate the output you want from that text file, that would be good too.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Newbie
    Joined
    Dec 2017
    Posts
    3
    Location
    Input text file1 has data as :

    type Z is

    record
    ***
    end record

    type Y is
    record
    ***
    end record
    type X is
    record
    ***
    end record
    type W is
    record
    ***
    end record


    Output text file2 should have only selected record data as :

    type X is
    record
    ***
    end record

    I think this will help and each record names are unique . TIA

  4. #4
    VBAX Newbie
    Joined
    Dec 2017
    Posts
    3
    Location
    Can i give line numbers or anything to find start line number and end line number of record? so that i can extract the data within that range ?

  5. #5
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    Quote Originally Posted by p45cal View Post
    A sample text file would help a lot.
    If you can indicate the output you want from that text file, that would be good too.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Posting Permissions

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