transcript

excelisfun - How To Import Text File into Excel (4 Examples, including Tab & CSV Files) – Excel Magic Trick 1619

Thumbnail of the video “excelisfun - How To Import Text File into Excel (4 Examples, including Tab & CSV Files) – Excel Magic Trick 1619”
Download Markdown
Community upload. AI output has not been independently verified.

In this video, we want to see how to import a text file into Excel. Often we get data that has the extension .txt, which means this is a text file. If we open it and look at it, field names are in the first row, records are in subsequent rows, and the delimiter, which just means what separates the bits of data, is a tab. If our goal is to import the text data into our Excel worksheet and we're using Excel 2013 or earlier, we go to Get External Data from Text, select our file, and click Import. This is the classic Text Import Wizard. It knows we have a delimiter, so be sure to check "My data has headers." We click Next. It knows that we have a tab-delimited file, and down below we can see the different columns and how the data has been separated. Next, when we select the column data format General, it will interpret dates, numbers, and text correctly. Click Finish, then click OK, and our data is imported into our Excel worksheet.

If we're in Excel 2016 or later, we go to the Get & Transform Data group in the Data ribbon tab, which is Power Query. Then we go to From Text/CSV, find our file, and click Import. It wants to know what the delimiter is. It guessed right. We come down to Load, then Load To, and it's going to load as an Excel Table, which of course has dynamic ranges. Existing worksheet is selected. Click OK. Now over here, in Queries & Connections, we can see that 5,000 rows have been loaded using Power Query. Over here in Connections, we can see this file was loaded using the Text Import Wizard. If either one of these text files changes, you can right-click and choose Refresh. Over here, even though it doesn't look like it's connected anywhere, we can right-click and refresh.

As a text file bonus, if we don't have a tab as a delimiter but a comma, then when we click From Text we see something like this. Click Import, and there it is. It picked up that this is a comma delimiter. Load To, click OK.

Bonus number two: what if you have a modern version of Excel and you don't want to import it as a table, but you want to use the legacy three-step wizard to just dump it as some data? Under Get Data, there are the Legacy Wizards, and the way you add this option is under File, Options, Data. Look at that. I happen to really like the "From Text (Legacy)" version. You can check whichever ones you'd like.

All right, that was a little fun with importing text files into Excel. If you want to learn more about loading data with Power Query, check out this video. If you want to see the legacy method, check out this video.