LoginSignup
0
1

More than 5 years have passed since last update.

メモ : csvを読み込んで縦横入れ替え in Ruby

Posted at

はじめに

メモです。

コード

array = []
File.open('csvfile').each do |l|
  array << l.chomp.split(',')
end
array.transpose.each do |a|
  puts a.join(',')
end

田中,佐藤,鈴木
1,2,3
10,20,30
100,200,300

これが、

田中,佐藤,鈴木
1,2,3
10,20,30
100,200,300

こうなる。

おわりに

Excelで出来ることには後で気づいた。

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