10
$\begingroup$

I have two list, just like

a={a1,a2,a3,a4};
b={b1,b2,b3,b4,b5};

I want merge them and save to excel, as they have different dimention, so I want it have the following format.

{{a1,b1},{a2,b2},{a3,b3},{a4,b4},{null,b5}}

and in the excel it will leave blank or fill some special words in the miss information position.

enter image description here

$\endgroup$

1 Answer 1

14
$\begingroup$

You can use Transpose + PadRight:

Transpose @ PadRight[{a,b}, Automatic, Null]

{{a1, b1}, {a2, b2}, {a3, b3}, {a4, b4}, {Null, b5}}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.