Tab delimited file not displaying correctly as table

I have a tab delimited .txt file that I’m simply loading into a variable but it’s like it’s not recognizing the tab and tossing everything in each row into the first column. The .txt file example is the following…

column1 column2 column3 column4 column5
1 2 3 4 5
2 5 4 6
4 4 6 4
4 5 6 4 6

And the PowerShell code is as follows…

$data = Import-Csv -Delimiter `t -Path C:\temp\testimport.txt&lt</strong>

<strong>$data | Format-Table</strong>

Any idea what the problem is? I thought `t was the correct switch for tab delimiting. Thanks in advance for any help on the issue.

It could be just the formatting on your post, but the data is single space delimited instead of tab delimited. Assuming the .txt file is actually tab delimited you need to specify the delimiter by escaping the literal “t” otherwise it is trying to look for a literal “t” character to delimit the data items. In PowerShell the backtick is the escape character. Here’s what it should look like.

$data = Import-Csv -Delimiter "`t" -Path "C:\temp\testimport.txt"