+ Reply to Thread
Results 1 to 7 of 7

Sort Text into Rows by Multiple Delimiters/Values

  1. #1
    Registered User
    Join Date
    11-19-2013
    Location
    Southern California
    MS-Off Ver
    Excel 2010
    Posts
    4

    Sort Text into Rows by Multiple Delimiters/Values

    Hello Excel Forum -

    I am trying to consolidate an .835 raw text file that is full of receipts and payments into rows by specific values/characters. Once opened within notepad/text format, I figured out that the ~CLP is the referencing value/character used to break up each individual payment.

    I need to somehow use the ~CLP as the value(s) to sort the text into new rows, with each row pre-leading with the ~CLP.

    For example:

    ~CLP*442.24*DTM*B6*PR~CLP*124.32...etc

    New Row format needed:

    ~CLP*442.24*DTM*B6*PR
    ~CLP*124.32

    Please let me know if more information is needed.

    Thank you in advance.
    Last edited by BoostThis; 11-21-2013 at 12:45 PM.

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Sort Text by Specific Delimiters/Values

    Data -> Text to column -> delimeted -> unctick all except the "other" type in the box ~ -> next-...
    that is Tilde just above the tab button in the keyboard
    now select the data click copy -> click a blank cell below ->paste special -> Transpose -> Ok
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  3. #3
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Sort Text by Specific Delimiters/Values

    ie data at A1 formula start at B1

    =TRIM(MID(SUBSTITUTE(A$1,"~",REPT(" ",100)&"~"),ROW(1:1)*100+1,100))

    copy down

  4. #4
    Registered User
    Join Date
    11-19-2013
    Location
    Southern California
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Sort Text by Specific Delimiters/Values

    Quote Originally Posted by vlady View Post
    Data -> Text to column -> delimeted -> unctick all except the "other" type in the box ~ -> next-...
    that is Tilde just above the tab button in the keyboard
    now select the data click copy -> click a blank cell below ->paste special -> Transpose -> Ok
    Thank you vlady. However, this will not work due to the fact that the text has multiple tilde symbols randomly throughout the file. The ~CLP is the only unique identifier I have to seperate what should truly be an individual row.

    I cannot also just use ~C because there are other lines that have ~CAS. THE ~CLP is the only unique identifier I have.

  5. #5
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Sort Text into Rows by Multiple Delimiters/Values

    just to answer using TTC

    use find and replace first
    find: ~~CLP
    replace: (alt+177)CLP (any alt key combination could suffice as long as it's not in the text/string itself )
    then Replace ALL

    then use that alt combination in the text-to-column

  6. #6
    Registered User
    Join Date
    11-19-2013
    Location
    Southern California
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Sort Text into Rows by Multiple Delimiters/Values

    Quote Originally Posted by vlady View Post
    just to answer using TTC

    use find and replace first
    find: ~~CLP
    replace: (alt+177)CLP (any alt key combination could suffice as long as it's not in the text/string itself )
    then Replace ALL

    then use that alt combination in the text-to-column
    Once again, thank you. Unfortunately, I'm beginning to come to the conclusion that because the raw text is not already sorted into rows before going into Excel, I may need a VBS to re-sort the file based on the ~CLP values/characters. Once this is complete and my text is in concurrent rows, I should then be able to import it into Excel, use Find and Replace against the ~CLP, and then break out the data using TTC.

    Thank you once again vlady.

  7. #7
    Registered User
    Join Date
    11-19-2013
    Location
    Southern California
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Sort Text into Rows by Multiple Delimiters/Values

    In case anyone is curious, here is the VB script I used. It took about 10 minutes to re-sort the text data:

    Const Path = "C:\Temp\all.txt"
    Const outPath = "C:\Temp\out.txt"


    With CreateObject("Scripting.FileSystemObject")
    Set inFile = .OpenTextFile(Path)
    Set outFile = .OpenTextFile(outPath, 2, True)
    End With

    count = 0
    Loop_count = 0
    sub_count = 1
    start_pos = 1
    whole_msg = inFile.ReadAll
    'msgbox(len(whole_msg))
    Do Until start_pos >= len(whole_msg)
    'msgbox(whole_msg)
    start_msg = Instr(start_pos,Cstr(whole_msg), "~CLP")
    'msgbox(start_msg)
    end_msg = Instr(start_Msg, Cstr(whole_msg), "~CAS")-1
    'msgbox(end_msg)
    msg = mid(Cstr(whole_msg),start_msg,end_msg - start_msg)
    start_pos = end_msg +2
    'msgbox(start_pos)
    'msgbox(msg)
    outFile.WriteLine msg
    count = count + 1



    Loop_count = Loop_count + 1

    If (Loop_count = 15000*sub_count) Then
    msgbox(Loop_count)
    msgbox(count)
    sub_count = sub_count + 1
    End if

    Loop

    function ReadList(listfile)

    const forReading = 1
    dim thelist()
    redim thelist(1)
    listLen = 0
    set theFSO = createobject("Scripting.FileSystemObject")
    set listFile = theFSo.openTextFile(listfile,forReading)

    while not listFile.atendofstream
    pcname = ltrim(rtrim(listFile.readline))
    if len(pcname)>1 and left(pcname,1)<>";" then
    if listlen = 0 then
    thelist(0) = pcname
    listlen = listlen+1
    else
    redim preserve thelist(listlen)
    thelist(listlen) = pcname
    listlen = listlen + 1
    end if
    end if
    wend

    listfile.close

    set listfile = nothing
    set thefso = nothing

    ReadList = theList

    end Function

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Use of multiple delimiters under Text To Columns
    By ryandonn in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-20-2013, 03:05 PM
  2. VBA splitting Text with Delimiters?
    By Irish RayRay in forum Excel General
    Replies: 6
    Last Post: 03-14-2012, 12:54 PM
  3. Text to columns with no delimiters
    By angies in forum Excel General
    Replies: 11
    Last Post: 08-15-2011, 08:24 AM
  4. Text to Column delimiters
    By sapling in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-20-2010, 04:48 PM
  5. [SOLVED] How To Import Text File With No Delimiters?
    By Sam in forum Excel General
    Replies: 1
    Last Post: 02-08-2005, 02:06 PM

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