TransWikia.com

How to preserve multirows when exporting TableForm results?

Mathematica Asked on February 12, 2021

I’ve created a table of data in Mathematica with a list of values with each data point. So for example, I have the following dummy data:

data = { {1 , {{1, 2}, {3, 4}, {5, 6}, {7, 8}}}, {2 , {{1, 2}, {3, 
     4}, {5, 6}, {7, 8}}}}

This turns into

data1 = TableForm[data]

    1   2
1   3   4
    5   6
    7   8

    1   2
2   3   4
    5   6
    7   8

When I export this as an excel file using the Export command, I get my initial data back (ie; the first cell is 1, the cell next to it is {{1, 2}, {3, 4}, {5, 6}, {7, 8}}}. I want my excel file to look similar to the table form, so I can import it into a Latex document. What’s the best way to do this? Is it possible/easy?

One Answer

Turn your data into a rectangular table:

data2 = Join @@@ Join @@ Transpose /@ MapAt[List /@ {#, "", "", ""} &, data, {All, 1}];

Export["tst.xls", data2]

enter image description here

Answered by kglr on February 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP