LoginSignup
4
3

More than 5 years have passed since last update.

PowerShellでCSVファイルを読み込む

Posted at

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

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

# CSVファイル(ヘッダあり、Shift-JIS)
$csvFile = "${baseDir}\TestData\Csv001_Data.csv"

# CSVファイルを読み込む
# PowerShell3.0では、Import-Csvの文字コード指定で、Shift-JISファイルを読み込み可能。
# PowerShell2.0だと、出来ないので、Get-Contentで使って、Shift-JISファイルを読み込み、
# ConvertFrom-Csvで、CSV→オブジェクト変換を行っています。
Get-Content $csvFile | ConvertFrom-Csv | %{
    $_ | Out-Default
}
4
3
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
4
3