LoginSignup
11
12

More than 5 years have passed since last update.

PowerShellでCSVファイルを書き込む

Posted at

こんな感じで出来ました。

詳細
https://github.com/kurukurupapa/TryPowerShell/blob/master/Csv002_Write.ps1

# サンプルデータ
$arr = @(
    @("1", "2", "3"),
    @("あ", "い", "う")
)

# 出力CSVファイル
$outCsvFile = "${baseDir}\TestResult\Csv002_Result.csv"

# CSVファイルを書き込む
# 文字コードはShift-JIS
$arr | %{
    New-Object PSObject -Property @{
        A = $_[0]
        B = $_[1]
        C = $_[2]
    }
} | Export-Csv -Encoding Default $outCsvFile
11
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
12