Home

How to import text file with 20,000 columns?

%3CLINGO-SUB%20id%3D%22lingo-sub-205956%22%20slang%3D%22en-US%22%3EHow%20to%20import%20text%20file%20with%2020%2C000%20columns%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-205956%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20to%20import%20txt%20file%20of%20500%20rows%20x%2020K-25K%20columns%3F%26nbsp%3B%20I%20have%20Excel%202010.%20Excel%20has%20this%20message%20after%20attempting%20to%20import%20by%20Data%26gt%3BFrom%20Text%26gt%3BImport%20text%20file%2C%20and%20using%20the%20Text%20Import%20Wizard%3A%3C%2FP%3E%3CP%3EThis%20message%20can%20appear%20due%20to%20one%20of%20the%20following%3A%3C%2FP%3E%3CUL%3E%3CLI%3EThe%20file%20contains%20more%20than%201%2C048%2C576%20rows%20or%2016%2C384%20columns.%20To%20fix%20this%20problem%2C%20open%20the%20source%20file%20in%20a%20text%20editor%20such%20as%20Microsoft%20Word.%20Save%20the%20source%20file%20as%20several%20smaller%20files%20that%20conform%20to%20this%20row%20and%20column%20limit%2C%20and%20then%20open%20the%20smaller%20files%20in%20Microsoft%20Excel.%20If%20the%20source%20data%20cannot%20be%20opened%20in%20a%20text%20editor%2C%20try%20importing%20the%20data%20into%20Microsoft%20Access%2C%20and%20then%20exporting%20subsets%20of%20the%20data%20from%20Access%20to%20Excel.%3C%2FLI%3E%3CLI%3EThe%20area%20that%20you%20are%20trying%20to%20paste%20the%20tab-delineated%20data%20into%20is%20too%20small.%20To%20fix%20this%20problem%2C%20select%20an%20area%20in%20the%20worksheet%20large%20enough%20to%20accommodate%20every%20delimited%20item.%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSTRONG%3ENotes%3C%2FSTRONG%3E%3C%2FP%3E%3CUL%3E%3CLI%3EExcel%20cannot%20exceed%20the%20limit%20of%201%2C048%2C576%20rows%20and%2016%2C384%20columns.%3C%2FLI%3E%3CLI%3EBy%20default%2C%20Excel%20places%20three%20worksheets%20in%20a%20workbook%20file.%20Each%20worksheet%20can%20contain%201%2C048%2C576%20rows%20and%2016%2C384%20columns%20of%20data%2C%20and%20workbooks%20can%20contain%20more%20than%20three%20worksheets%20if%20your%20computer%20has%20enough%20memory%20to%20support%20the%20additional%20data.%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3BI%20don't%20think%20it%20is%20feasible%20to%20reduce%20the%20column%20%23%20in%20Word%20or%20Notepad.%26nbsp%3B%20I%20can't%20see%20any%20columns%20so%20I%20can't%20remove%20columns.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExcel%20recommends%20that%20the%20user%20save%20the%20first%20import%20that%20is%20truncated%20table%20of%20the%20txt%20file%20to%20one%20sheet%2C%20and%20then%20import%20a%20second%20time%20to%20a%20second%20sheet%20only%20those%20columns%20needed%20to%20complete%20the%20whole%20table.%26nbsp%3B%26nbsp%3BThe%20problem%20is%20that%20Excel%20does%20not%20present%20a%20feasible%20option%20to%20preview%20all%20the%20columns%20in%20the%20Text%20Import%20Wizard%2C%20so%20there%20is%20no%20way%20to%20remove%20the%20unwanted%20columns%20before%20importing%20into%20the%20second%20sheet.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20also%20tried%20Power%20Query%2C%20but%20that%20locks%20up%20and%20is%20unable%20to%20work%20with%20the%20data%20in%20preview%20mode%2C%20to%20e.g.%20first%20split%20the%20single%20column%20into%20the%2020K%20columns%20and%20then%20to%20remove%20columns.%26nbsp%3B%20Also%2C%20it%20is%20not%20possible%20to%20transpose%20the%20text%20file%20contents%20with%20PQ%20before%20importing.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMaybe%26nbsp%3Bimport%20the%20data%20into%20the%20Data%20Model%20i.e.%20PowerPivot%20via%20Power%20Query%20would%20work%3F%26nbsp%3B%20I%20can%20try.%3C%2FP%3E%3CP%3EThank%20you%2C%3C%2FP%3E%3CP%3ERalph%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-205956%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-206530%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20import%20text%20file%20with%2020%2C000%20columns%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-206530%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Ralph%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20my%20point%20of%20view%26nbsp%3Bthe%20best%20way%20is%20to%20connect%20directly%20to%20the%20database%20and%20filter%20the%20data%20on%20query%20level.%20The%20only%20most%20probably%20some%20coding%20will%20be%20required%2C%20not%20sure%20you%20may%20filter%20data%20with%20UI%20due%20to%20columns%20limit.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20Power%20Pivot%20in%20your%20version%20of%20Excel%20you%20may%20try%20to%20connect%20to%20database%20or%20to%20text%20file%20directly%20from%20Power%20Pivot%2C%20data%20model%20has%20another%20structure%20in%20background%20and%20no%20direct%20limits%20on%20columns.%20If%20works%2C%20result%20could%20be%20landed%20to%20Excel%20sheet%20as%20normal%20table%2C%20not%20as%20Pivot%20Table.%20-%20if%20you%20reduce%20number%20of%20columns%20within%20the%20data%20model.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-206492%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20import%20text%20file%20with%2020%2C000%20columns%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-206492%22%20slang%3D%22en-US%22%3E%3CP%3EDear%20Sergei%2C%3C%2FP%3E%3CP%3EIf%20the%20original%20data%20had%20been%20transposed%20prior%20to%20saving%20in%20the%20text%20file%2C%20there%20would%20be%20no%20problem%3B%2020%2C000%20rows%20x%20500%20columns%20is%20easy%20to%20import.%26nbsp%3B%20The%20data%20set%20would%20be%20ready%20to%20mine.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20your%20recommendation%2C%20but%20it%20may%20not%20be%20suitable%20for%20the%20structure%20of%20my%20data%20set.%26nbsp%3B%26nbsp%3BI%20am%20able%20to%20import%20big%20blocks%20of%20merged%20columns%20using%20the%20text%20import%20wizard%20based%20on%20fixed%20width%2C%20but%20defining%20the%20fixed%20widths%20is%20tough%20to%20do%20in%20the%20tiny%20preview%20window%2C%20and%20then%20deleting%20some%20blocks%20so%20that%20the%20total%20is%20less%20than%20the%2016%2C384%20excel%20limit%20requires%20some%20guessing%2C%20and%20then%20matching%20the%20data%20columns%20(not%20in%20quotes)%20to%20the%26nbsp%3Bcolumn%20names%26nbsp%3B(are%20in%20quotes)%2C%26nbsp%3Bbecause%20they%26nbsp%3Bare%20not%20aligned%2C%26nbsp%3Bmakes%20it%20even%20more%20difficult.%26nbsp%3B%20Separating%20the%20blocks%20of%20columns%20into%20columns%20in%20excel%20worked%20well%20except%20for%20the%20cells%20on%20the%20left%20and%20right%20edges%20of%20the%20blocks.%26nbsp%3B%20These%20cells%20lost%20data%20to%20adjacent%20blocks.%26nbsp%3B%20There%20must%20be%20another%20solution.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20might%20be%20best%20to%20(1)%20split%20the%20original%20text%20file%20and%20import%20into%20excel%20into%20two%20different%20sheets%2C%20transpose%20each%2C%20and%20then%20combine%2C%20or%20(2)%20use%20a%20macro%20in%20excel%20to%20import%2C%20or%20(3)%20maybe%20use%20a%20pivot%20table%20if%20this%20is%20possible%2C%20to%20connect%20to%20the%20remote%20text%20file%20with%2020K%20columns%2C%20and%20import%20or%20add%20to%20the%20destination%20sheet's%20pivot%20table%20just%2010K%20columns%20or%20transpose%20them%20to%20rows%2C%20but%20I%20am%20not%20sure%20how%20to%20automate%20this.%26nbsp%3B%20The%20main%20point%20of%20(3)%20is%20to%20have%20the%20excel%20file%20connect%20to%20a%20source%20text%20file%20or%20database%20to%20extract%20just%20what%20is%20called%20up%20to%20avoid%20exceeding%20the%2016K%20limit%20on%20columns.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20do%20you%20recommend%3F%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3ERalph%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-206103%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20import%20text%20file%20with%2020%2C000%20columns%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-206103%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Ralph%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPower%20Query%20has%20exactly%20the%20same%20limit%20on%20number%20of%20colums%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fsupport.office.com%2Fen-us%2Farticle%2Fpower-query-specifications-and-limits-5fb2807c-1b16-4257-aa5b-6793f051a9f4%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsupport.office.com%2Fen-us%2Farticle%2Fpower-query-specifications-and-limits-5fb2807c-1b16-4257-aa5b-6793f051a9f4%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPerhaps%20you%20may%20import%20your%20txt%20with%20dividing%20on%20columns%20not%20by%20delimiter%2C%20but%20using%20Fixed%20width%2C%203-4%20separate%20imports%20and%20split%20on%20columns%20each%20of%20them%20with%20some%20combining%20after%20that.%20But%20that%20very%20depends%20on%20your%20data%20structure.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-917366%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20import%20text%20file%20with%2020%2C000%20columns%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-917366%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Sergei%2C%3C%2FP%3E%3CP%3EYes%2C%20I%20upgraded%20to%20Excel%202019%2C%20so%20have%20access%20to%20Power%20Pivot%2C%20but%20I%20can't%20see%20an%20option%20for%20importing%20part%20of%20the%20text%20file%20into%20the%20data%20model%2C%20and%20don't%20understand%20the%20method%20for%20dividing%20the%20data%20in%20the%20model%20even%20if%20I%20knew%20how%20to%20import%20the%20entire%20text%20file%20into%20the%20data%20model.%3C%2FP%3E%3CP%3ECan%20you%20explain%20or%20point%20me%20to%20a%20resource%20that%20describes%20this%3F%3C%2FP%3E%3CP%3EOther%20possible%20options%20include%20dividing%20the%20text%20file%20in%20a%20text%20editor%2C%20but%20I%20don't%20know%20how%20to%20use%20an%20editor%20like%20Word%20to%20begin%20dividing%20a%20file%20with%20e.g.%2024%2C000%20columns%20into%20two%20files.%3C%2FP%3E%3CP%3ECan%20R%20or%20the%20command%20line%20be%20used%20to%20transpose%20or%20divide%20text%20files%3F%3C%2FP%3E%3CP%3EThank%20you%2C%3C%2FP%3E%3CP%3ERalph%3C%2FP%3E%3C%2FLINGO-BODY%3E
Ralph Puchalski
Occasional Contributor

How to import txt file of 500 rows x 20K-25K columns?  I have Excel 2010. Excel has this message after attempting to import by Data>From Text>Import text file, and using the Text Import Wizard:

This message can appear due to one of the following:

  • The file contains more than 1,048,576 rows or 16,384 columns. To fix this problem, open the source file in a text editor such as Microsoft Word. Save the source file as several smaller files that conform to this row and column limit, and then open the smaller files in Microsoft Excel. If the source data cannot be opened in a text editor, try importing the data into Microsoft Access, and then exporting subsets of the data from Access to Excel.
  • The area that you are trying to paste the tab-delineated data into is too small. To fix this problem, select an area in the worksheet large enough to accommodate every delimited item.

Notes

  • Excel cannot exceed the limit of 1,048,576 rows and 16,384 columns.
  • By default, Excel places three worksheets in a workbook file. Each worksheet can contain 1,048,576 rows and 16,384 columns of data, and workbooks can contain more than three worksheets if your computer has enough memory to support the additional data.

 I don't think it is feasible to reduce the column # in Word or Notepad.  I can't see any columns so I can't remove columns.

 

Excel recommends that the user save the first import that is truncated table of the txt file to one sheet, and then import a second time to a second sheet only those columns needed to complete the whole table.  The problem is that Excel does not present a feasible option to preview all the columns in the Text Import Wizard, so there is no way to remove the unwanted columns before importing into the second sheet.

 

I also tried Power Query, but that locks up and is unable to work with the data in preview mode, to e.g. first split the single column into the 20K columns and then to remove columns.  Also, it is not possible to transpose the text file contents with PQ before importing.

 

Maybe import the data into the Data Model i.e. PowerPivot via Power Query would work?  I can try.

Thank you,

Ralph

4 Replies

Hi Ralph,

 

Power Query has exactly the same limit on number of colums https://support.office.com/en-us/article/power-query-specifications-and-limits-5fb2807c-1b16-4257-aa...

 

Perhaps you may import your txt with dividing on columns not by delimiter, but using Fixed width, 3-4 separate imports and split on columns each of them with some combining after that. But that very depends on your data structure.

Dear Sergei,

If the original data had been transposed prior to saving in the text file, there would be no problem; 20,000 rows x 500 columns is easy to import.  The data set would be ready to mine.

 

I tried your recommendation, but it may not be suitable for the structure of my data set.  I am able to import big blocks of merged columns using the text import wizard based on fixed width, but defining the fixed widths is tough to do in the tiny preview window, and then deleting some blocks so that the total is less than the 16,384 excel limit requires some guessing, and then matching the data columns (not in quotes) to the column names (are in quotes), because they are not aligned, makes it even more difficult.  Separating the blocks of columns into columns in excel worked well except for the cells on the left and right edges of the blocks.  These cells lost data to adjacent blocks.  There must be another solution. 

 

It might be best to (1) split the original text file and import into excel into two different sheets, transpose each, and then combine, or (2) use a macro in excel to import, or (3) maybe use a pivot table if this is possible, to connect to the remote text file with 20K columns, and import or add to the destination sheet's pivot table just 10K columns or transpose them to rows, but I am not sure how to automate this.  The main point of (3) is to have the excel file connect to a source text file or database to extract just what is called up to avoid exceeding the 16K limit on columns.

 

What do you recommend?

Thanks,

Ralph

Hi Ralph,

 

From my point of view the best way is to connect directly to the database and filter the data on query level. The only most probably some coding will be required, not sure you may filter data with UI due to columns limit.

 

If you have Power Pivot in your version of Excel you may try to connect to database or to text file directly from Power Pivot, data model has another structure in background and no direct limits on columns. If works, result could be landed to Excel sheet as normal table, not as Pivot Table. - if you reduce number of columns within the data model.

@Sergei Baklan 

Hi Sergei,

Yes, I upgraded to Excel 2019, so have access to Power Pivot, but I can't see an option for importing part of the text file into the data model, and don't understand the method for dividing the data in the model even if I knew how to import the entire text file into the data model.

Can you explain or point me to a resource that describes this?

Other possible options include dividing the text file in a text editor, but I don't know how to use an editor like Word to begin dividing a file with e.g. 24,000 columns into two files.

Can R or the command line be used to transpose or divide text files?

Thank you,

Ralph

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies