+ Reply to Thread
Results 1 to 19 of 19

Import .txt to Excel?

  1. #1
    Registered User
    Join Date
    10-26-2018
    Location
    Moscow, Russia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Question Import .txt to Excel?

    Hey! I have enormous amount of data in .txt which I need to be converted to Excel. Data looks like this:

    AhAs3s2s(at)100,AdAs3s2s(at)100,AcAs3s2s(at)100,AhKh3s2s(at)100,AdAh3s2s(at)100,AcAh3s2s(at)100,AdKd3s2s(at)100,AcAd3s2s(at)100,AcKc3s2s(at)100,AhA s4s2s(at)100,AdAs4s2s(at)100,AcAs4s2s(at)100,AhKh4s2s(at)100, (...) (I didn't use (at) sign because then I get errors which don't let me post a thread)

    Outcome has to be like this:

    [ COLUMN 1 ][ COLUMN 2 ]
    [ AhAs3s2s ][ 100 ]
    [ AdAs3s2s ][ 100 ]
    [ AcAs3s2s ][ 100 ]
    [ AdAh3s2s ][ 100 ]
    etc.

    I tried so many things and came nowhere close to the final result. Is there anyone able to help me?

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Import .txt to Excel?

    As suggested in your other thread, will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    10-26-2018
    Location
    Moscow, Russia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Re: Import .txt to Excel?

    Ok I did it in Excel (added attachment)
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Import .txt to Excel?

    I tried so many things and came nowhere close to the final result. Is there anyone able to help me?
    Are you tried "Text to Columns" option with Delimited="@"?

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Import .txt to Excel?

    Done in two steps using Power Query (Get & Transform), which you should have on your Data ribbon. Here's the M code:

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

  6. #6
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Import .txt to Excel?

    or you may import text file from Data>>From Text >>Delimited>>Other=@

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Import .txt to Excel?

    I think most people are missing the fact that the data is all in one cell and there is the comma to deal with first to get the data into rows.

  8. #8
    Registered User
    Join Date
    10-26-2018
    Location
    Moscow, Russia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Re: Import .txt to Excel?

    mohan.r1980 Yes, I tried that way, it didn't work tho, I couldn't make it into rows

    AliGW That's amazing! I'm truly impressed. Is there any tutorial on how to use your code?
    Last edited by SanSebastian66; 10-26-2018 at 06:24 AM.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Import .txt to Excel?

    Who are you talking to? Have you tried my suggestion???

  10. #10
    Registered User
    Join Date
    10-26-2018
    Location
    Moscow, Russia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Re: Import .txt to Excel?

    Yes, I'm sorry it's hard to reply here without getting an error. I answered to your reply in edit.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Import .txt to Excel?

    I will write a quick tutorial and post it here. Give me fifteen minutes and then check back.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Import .txt to Excel?

    Power Query: Data from One Cell to Rows & Columns

    1. With your data all in cell A1, select cell A1 and go to the Data ribbon – click on From Table/Range in the Get & Transform section – do NOT tick My table has headers. This will load your data into Power Query.
    2. In the PQ window, select the drop-down under Split Column on the Home ribbon and choose By Delimiter. In the dialog, select comma from the drop-down and in the advanced section, select Rows – leave everything else as it is and click OK.
    3. Again select the drop-down under Split Column on the Home ribbon and choose By Delimiter. In the dialog, select custom from the drop-down and type @ into the box, then click OK.
    4. Choose Close & Load from the Home ribbon. Your new table will now appear in the Excel workbook.

    The code I posted before is generated by taking these steps.
    Last edited by AliGW; 10-26-2018 at 06:42 AM.

  13. #13
    Registered User
    Join Date
    10-26-2018
    Location
    Moscow, Russia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Re: Import .txt to Excel?

    Thank you very much! However I somehow can't find "Rows" in advanced section. It's just not there (probably different Office version). I attach screenshot from my "split column by delimiter" window:
    Attached Images Attached Images

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Import .txt to Excel?

    Ah! This means you do not have the latest version of Power Query and it's a new option. Never mind - let me see if I can find a workaround for you. Give me ten minutes!

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Import .txt to Excel?

    Try this instead:

    Power Query: Data from One Cell to Rows & Columns


    1. With your data all in cell A1, select cell A1 and go to the Data ribbon – click on From Table/Range in the Get & Transform section – do NOT tick My table has headers. This will load your data into Power Query.
    2. In the PQ window, select the drop-down under Split Column on the Home ribbon and choose By Delimiter. In the dialog, select comma from the drop-down and click OK.
    3. On the Transform ribbon, select Transpose.
    4. Again select the drop-down under Split Column on the Home ribbon and choose By Delimiter. In the dialog, select custom from the drop-down and type @ into the box, then click OK.
    5. Choose Close & Load from the Home ribbon. Your new table will now appear in the Excel workbook.

  16. #16
    Registered User
    Join Date
    10-26-2018
    Location
    Moscow, Russia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Re: Import .txt to Excel?

    That's incredible. Thank you very much! Yet for some reason it shows only 2.5k rows and I expect somewhere between 20-30k, do u have any idea why would that be? If not, I'm just gonna divide .txt into 10 smaller pieces and work with that. Thank you again!

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Import .txt to Excel?

    It may be a limitation in PQ - not sure, as I have not worked with such large data myself. Splitting it into manageable chunks will work. PQ is a really great tool - have a play with it to see what else it can do.

  18. #18
    Registered User
    Join Date
    10-26-2018
    Location
    Moscow, Russia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Re: Import .txt to Excel?

    I'm forever grateful

  19. #19
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Import .txt to Excel?

    Glad to help!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Import Multiple Excel Work Sheets into Master excel file using VBA
    By hanan_ak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2018, 11:08 AM
  2. Import data from excel files with specific file name into another excel sheet
    By Nicolina in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-05-2017, 11:42 AM
  3. VBA to Import Specific Range of data from multiple excel files into 1 excel file
    By ykim322 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-13-2016, 04:18 PM
  4. Import Access query results into Excel show import status
    By mwatson4788 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-06-2016, 10:12 AM
  5. Import web data into excel does not import picture, how to substitute picture for a value
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2012, 03:29 AM
  6. Adobe forms - possible to import data into excel? Make form from excel?
    By frankienap in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-15-2012, 11:29 AM
  7. Import another excel Paste data in Current open excel sheet
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-28-2012, 09:47 AM

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