Import-CSV in PowerShell hides double quotes

I import a file and process its contents like this:

$msg = Import-Csv .\content -Delimiter "`t" | Select msg | Format-Table -HideTableHeaders | Out-String | %{$_ -replace "\n"}

      

In this case, the content file looks like this:

id  name    when    ip  msg user_id
 50 Felix   2015-07-22 12:51:04 10.1.100.6  "ein link":www.link.de  89

      

But $ msg returns the following:

ein link:www.link.de

      


When I have a content file like:

id  name    when    ip  msg user_id
 50 Felix   2015-07-22 12:51:04 10.1.100.6  dies ist "ein link":www.link.de 89

      

$ msg is correct:

dies ist "ein link":www.link.de

      

Import-CSV only hides double quotes when they appear at the beginning of text.

I am working with PowerShell 5.0

Can you help me?

thank

+3


source to share


1 answer


try it, maybe it works:



$msg = Get-Content .\content.csv |
       ForEach-Object { $_ -replace ('"','"""') } | 
       ConvertFrom-CSV -Delimiter "`t" | 
       Select msg | Format-Table -HideTableHeaders | 
       Out-String | %{$_ -replace "\n"}

      

+1


source







All Articles