2
$\begingroup$

I would like to combine some pieces of data and export the data to Excel, but I need to insert some empty cells between pieces of data as the delimiter. For example, I have two lists listA={1,2,3}, listB={4,5,6}, and I want to add two empty cells between the two parts to look like this in the exported Excel file

enter image description here

One way I can think of is to include some empty items in the final list to export, e.g., listFinal={1, 2, 3, , , 4, 5, 6}, then Export[filepath + name, listFinal]. But I could not figure out how to produce listFinal from listA and listB with those empty items inserted. Or is there a better way to do this?

$\endgroup$
6
$\begingroup$

You can use Null for the empty elements e.g.

Export["foo.xlsx", listA~Join~{Null, Null}~Join~listB]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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