Skip to content

Combining Multiple Columns

Andy Meneely edited this page Mar 16, 2016 · 1 revision

Combining Multiple Columns

Say you have multiple columns in your Excel sheet that need to be combined into one text field on your card. Consider using zip in conjunction with map.

data['BuyText'] = data['BuyAmount'].zip(data['BuyType']).map do |amt, type|
  "You may purchase #{amt} #{type}" #e.g. You may purchase 1 Wood.
end

data['Cost'] = data['Action Cost'].zip(data['Card Cost']).map do |ac, cc|
  ':action:' * ac.to_i + ":card#{cc}:"
end

Second example adapted from this conversation

Clone this wiki locally