mercredi 21 décembre 2016

Splitting values in Hashmap

I have a hashmap in the following format:

{"PPS_Id"=>["fe4d7c06-215a-48a7-966d-19ab58976548", "6e90208e-4ab2-4d44-bbaa-9a874bff095b"], "Amount"=>"[#<BigDecimal:7fcb1e0904c0,'0.1E5',9(18)>, #<BigDecimal:7fcb1e08a4a8,'0.2374E4',9(18)>]"}

When I write this data into an excel get the following output. enter image description here I want to write the data into the Excel this way:

PPS_Id                                     Amount
fe4d7c06-215a-48a7-966d-19ab58976548       12345
6e90208e-4ab2-4d44-bbaa-9a874bff095b       12345

How do I convert my current Hash to the below:

{PPS_Id"=>["fe4d7c06-215a-48a7-966d-19ab58976548","Amount"=>"12345"},{PPS_Id"=>["6e90208e-4ab2-4d44-bbaa-9a874bff095b","Amount"=>"12345"}

Also, when I use .value.to_s to convert the BigDecimal value in hash to an integer, It doesn't seem to work.

Can you please assist.

Aucun commentaire:

Enregistrer un commentaire