Tab delimited file not displaying correctly as table

Welcome Forums General PowerShell Q&A Tab delimited file not displaying correctly as table

Viewing 2 reply threads
  • Author
    Posts
    • #282817
      Participant
      Topics: 2
      Replies: 1
      Points: 14
      Rank: Member

      I have a tab delimited file that I’m simply trying to display as a table in PowerShell. For some reason it’s combining everything on each row into the first column rather than separating on the tab as it should. The PowerShell code is as follows….

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

      $data | Format-Table

      Looking at the file in Notepad++ shows a CR/LF at the end of every line and a tab separating all of the values. The only oddity being that some rows don’t have a value for every single column. The file looks like 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

      Any help on how to get this to display properly would be appreciated, thanks.

    • #282826
      Participant
      Topics: 5
      Replies: 10
      Points: 93
      Rank: Member

      Are you sure you have tabs separating the headers and number values?

      This is what I get with the code below. It is not obvious from the copy/paste, but each number is aligned with its corresponding column

      $data = Import-Csv -Delimitert -Path c:\temp\testimport.txt`
      $data | FT

      • This reply was modified 3 weeks, 1 day ago by obijuan.
      • This reply was modified 3 weeks, 1 day ago by obijuan.
    • #282838
      Participant
      Topics: 2
      Replies: 1
      Points: 14
      Rank: Member

      Yep… I’m an idiot…. After reviewing it in Notepad++ it appears it was spaces and not tabs. Thanks though, works fine now.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.