Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = FasterCSV.read("meta_docs/verticals_plus_reasons.csv")
- # Largest row
- size = a.max { |r1, r2| r1.size <=> r2.size }.size
- # Enlarge matrix inserting nils as needed
- a.each { |r| r[size - 1] ||= nil }
- # So now a == [[1, 2, 3], [3, 4, nil]]
- aa = a.transpose
- FasterCSV.open("meta_docs/vertials_plus_reasons_transposed.csv", "w+") do |csv|
- aa.each {|row|
- csv << row
- }
- end
Add Comment
Please, Sign In to add comment