If I have several lists such as:

alllists={{{30.,0.538342}, {30.1667, 0.53829}, {30.3333, 0.537987}......{{30., 0.527173}, {30.1667, 0.527403}, {30.3333, 0.527863}, {30.5,0.528402}, {30.6666, 0.528819}, {30.8333, 0.529406}, {30.9999, 
  0.530284}, {{}......................}}}

How can I import the lists to excel?. Specifically, how can I import the first list to the first two columns (the x and y parts of the list in different columns), the second to the following columns and so on?

  • $\begingroup$ Export["file.xlsx",alllists] should work. What's the problem? $\endgroup$ – bobthechemist Apr 5 at 0:31
  • $\begingroup$ @bobthechemist thanks but the problem is that it exports the list into different "sheets" is there any way to export it into the same excel sheet in different columns? $\endgroup$ – John Apr 5 at 0:40
  • $\begingroup$ Probably. You should provide a MWE to work with. $\endgroup$ – bobthechemist Apr 5 at 0:58
  • $\begingroup$ See XLSX. From the point of view transferring the data from within Mathematica, the operation is Export. Import would transfer data from Excel into Mathematica. So you'd probably be interested in the information about exporting to Excel in the link. $\endgroup$ – Michael E2 Apr 5 at 2:37

Generate some fake data. I'm assuming this is what your list looks like.

data = Range[100];
datap = Partition[ Partition[data, 2], 10];

Each list is of the same length, so exporting can be done with Export["filename.xlsx",MapThread[Join@##&, datap]. If, however, your lists are not all the same length:

datap1 = With[{d = Partition[data, 2]}, {d[[1 ;; 5]], d[[6 ;; 15]], 
   d[[16 ;; 30]], d[[31 ;; 50]]}]

Then they need to be padded first:

 MapThread[Join@## &, 
  PadRight[#, Max[Length /@ datap1], {{Null, Null}}] & /@ datap1]]

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.