+ Reply to Thread
Results 1 to 8 of 8

Importing delimited text into columns vice rows

  1. #1
    Registered User
    Join Date
    11-02-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Importing delimited text into columns vice rows

    I have a few text files that contain repetitive data that I want to be able to import into a spreadsheet.

    An example of the data is:

    Name: Joe Smith
    Address: 123 S. Street
    City: New York
    Phone: 1231231234
    Name: Sam Jones
    Address: 321 S. Street
    City: New York
    Phone: 3213214321

    I have multiple sets of similar data contained in multiple text files. I would like to create a template that I point to a single text file and import the data so that it looks like this:
    Name Address City Phone
    Joe Smith 123 S. Street New York 1231231234
    Sam Jones 321 S. Street New York 3213214321

    All the data is delaminated by a colon and I can get it into rows but I want to be able to sort and I don’t want the data to the left of the colon repeated.

    Any help would be appreciated.

    Thanks

    Scott

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Importing delimited text into columns vice rows

    If you can provide a sample of two of the text files, the files don't need to have a lot of data, a few sample addresses in each, and also an Excel workbook showing the exact results expected from those two sample text files, we can probably set you up with an import macro.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Importing delimited text into columns vice rows

    Hi..

    There is probably a more elegant way of allocating the values to the xx array.. but this will do the job and should be quick.

    Npte: This assumes your text files are same format as the block of data you posted in the 1st post.

    Please Login or Register  to view this content.
    Last edited by apo; 07-15-2014 at 09:10 PM. Reason: Add TRIM to remove leading space..

  4. #4
    Registered User
    Join Date
    11-02-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Importing delimited text into columns vice rows

    Thank you for the speedy replies. I can’t post the actual data fields or a sample of the data, it is proprietary. I will try to explain in more detail what I would like to do.

    I have looked at the code that apo posted and it looks promising just needs to be tweeked a bit for my application.

    Block = entire data set between solid lines.
    Item = line of text with unique title to the left of colon and unique data to the right of colon

    I have multiple text files that contain multiple sections with 12 different pieces of data. I only wish to do one text file per import. The data is formatted like in my example of the address below, (but there are 12 different lines). Each 12 item block, is separated by a solid line (which I don’t need to import). Each block of 12 items contains the same title to the left of the colon but different data to the right. The data to the right of the colon could be a paragraph of text or a single number, it is variable.
    ____________________________
    Name: Joe Smith
    Address: 123 S. Street
    City: New York
    Phone: 1231231234
    ____________________________
    Name: Sam Jones
    Address: 321 S. Street
    City: New York
    Phone: 3213214321
    ____________________________

    What I would like to do is have the data to the left of each colon as my column headings. There will be 12 which I can set up ahead of time in my template, it will never change. Then I would like to pull the data to the right of each colon and populate the appropriate data under each heading starting on row 2 so it looks like this”

    A B C D
    1Name Address City Phone
    2Joe Smith 123 S. Street New York 1231231234
    3Sam Jones 321 S. Street New York 3213214321

    The goal of this is to be able to sort and filter the data based on the content of each column.

    I hope this makes what I am trying to do clearer.

    Thanks
    Scott
    Last edited by Barchetta; 07-16-2014 at 10:18 AM.

  5. #5
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Importing delimited text into columns vice rows

    Hi..

    What I would like to do is have the data to the right of each colon as my column headings
    I think you mean "to the left of each colon..."?

    I can’t post the actual data fields or a sample of the data, it is proprietary.
    You would be much better off creating a dummy Workbook and dummy text files.. basically.. exactly what JBeaucaire says in post #2.

    The code i posted worked perfectly for the dummy data you posted in your first post.. so.. you can either recreate your scenario (like I did with the data you posted).. and try to adapt it to your exact situation.. or attach some sample (non proprietary data) text file(s).. and a Workbook showing desired result..

  6. #6
    Registered User
    Join Date
    11-02-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Importing delimited text into columns vice rows

    Yes apo you are correct with the left/right typo original post edited.

    I will put something together today and post it.

    Thanks for all your assistance.

    Scott

  7. #7
    Registered User
    Join Date
    11-02-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Importing delimited text into columns vice rows

    Please find a sample text file and an example workbook with desired results attached.

    Example of workbook.xlsx
    sample text file.txt


    Once again thank you for all the assistance.

    Scott
    Last edited by Barchetta; 07-16-2014 at 12:01 PM.

  8. #8
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Importing delimited text into columns vice rows

    Hi..

    This should do it..

    I did a bit of a workaround as your textfile had blank rows and other unwanted characters(the line between each block of data).

    So i brought all the data into a Helper sheet.. autofiltered and removed the unwanted rows.. then used that resulting data for the array..

    Still not the most elegant.. but it will work..

    Try the attached file on your text file you uploaded..

    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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. [SOLVED] Organize large space delimited text file into appropriate rows and columns in excel.
    By rdlaner in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-29-2013, 02:25 PM
  2. Importing Delimited Text File
    By JHCross in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-25-2011, 06:01 PM
  3. Importing Delimited Text file
    By mmb.kala in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-23-2010, 02:45 AM
  4. Importing Delimited Text/Exporting Delimited Text Loop
    By cecarter74 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-05-2009, 01:17 PM
  5. Importing space delimited text file
    By EDIEC in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2008, 03:44 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