LoginSignup
2
1

More than 5 years have passed since last update.

PowerShellでCSVを縦横変換する

Last updated at Posted at 2018-02-24

PowerShellでCSVを縦横変換する

データ分析の際に使用するので、備忘録として...

横に並んだ配列を...

$csv = @(Get-Content in.csv )
$csv
a,b,c,d,e
1,2,3,4,5

縦に変換します

for($i=0; $i -lt 5; $i++){$csv[0].Split(",")[$i] + "," + $csv[1].Split(",")[$i]}
a,1
b,2
c,3
d,4
e,5

CSVに出力します

for($i=0; $i -lt 5; $i++){Add-Content Path "out.csv" -Value ($csv[0].Split(",")[$i] + "," + $csv[1].Split(",")[$i])} 

職人的ではありませんが、素人でもわかるスクリプトだと思います

2
1
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
2
1