Skip to content

Instantly share code, notes, and snippets.

@gongo
Created June 24, 2019 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gongo/cb8f63fa258f513acaa93ff9be6047fb to your computer and use it in GitHub Desktop.
Save gongo/cb8f63fa258f513acaa93ff9be6047fb to your computer and use it in GitHub Desktop.
ヘッダが異なる CSV::Row を混ぜていい感じに csv 作りたい
row1 = CSV::Row.new(['a', 'b'], [1, 2])
row2 = CSV::Row.new(['a', 'c'], [4, 12])
table = CSV::Table.new([row1, row2])
table.to_s
#
# expected:
#
# a,b,c
# 1,2,
# 4,,12
#
# actual:
#
# a,b
# 1,2
# 4,12
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment