【发布时间】:2014-02-18 18:11:39
【问题描述】:
我需要使用 powershell 将以下文本写入 csv 文件
这是一段文字,用来说明逗号和“双 引号”。因此,它非常重要
我正在使用流编写器及其 writeline() 来实现上述目的。但是,字符串“双引号”之后的第一个逗号之后的文本在输出文件中的两个单元格中被拆分。
我的输出是这样的:
单元格 1 的内容:这是一个文本,用于展示 逗号和“双引号”。因此
单元格2的内容:很重要
如何让整个输入文本只显示在一个单元格中?
这是我的代码 sn-p
$id = '12345'
$preamble = 'This is a text, to demonstrate the importance of comma and the "Double Quotes". Hence, it is very important'
$filename = "Comma.csv"
$currentDir = Get-Location
$outputcsv = Join-Path $currentDir $filename
$str = [System.IO.StreamWriter] $outputcsv
$newrow = "$id,`"$preamble`""
$str.WriteLine($newrow)
$str.Close()
【问题讨论】:
标签: powershell csv comma