2
$\begingroup$

I have multiple lists like this this with different lengths and different x, y values,

list1 = {{3., 1.49463}, {3.1, 1.49238}, {3.2, 1.49027}, {3.3, 1.48814}, {3.4, 
  1.48592}, {3.5, 1.48366}, {3.6, 1.48158}, {3.7, 1.47997}, {3.8, 
  1.47894}, {3.9, 1.47848}, {4., 1.47824}, {4.1, 1.47892}, {4.2, 
  1.47973}, {4.3, 1.4809}, {4.4, 1.48231}, {4.5, 1.48374}, {4.6, 
  1.48498}, {4.7, 1.48589}, {4.8, 1.4865}, {4.9, 1.4869}, {5., 
  1.48717}};

list2 = {{0.3, 1.70796}, {0.4, 1.69032}, {0.5, 1.66887}, {0.6, 1.65187}, {0.7,
   1.64455}, {0.8, 1.64575}, {0.9, 1.65089}, {1., 1.65581}};

list3 ={{4.1, 1.47892}, {4.2, 1.47973}, {4.3, 1.4809}, {4.4, 1.48231}, {4.5, 
  1.48374}, {4.6, 1.48498}, {4.7, 1.48589}, {4.8, 1.4865}, {4.9, 
  1.4869}, {5., 1.48717}};

and so on until 10 lists and all of them have different lengths with some having (x,y) sets as much as 30 (x1,y1),(x2,y2) ... (x30,y30) like that,

i want to list them list this in single excel sheet with two different options whichever you can guide,

list 1 x,y values (next list after two columns separation) -list 2 x,y values- (next list after two columns separation) -**list 3 x,y values****

list 1 x,y values (no separation)- list 2 x,y values- (no separation)- list 3 x,y values

$\endgroup$
4
$\begingroup$

Does this do what you want?

array = Riffle[{list1, list2, list3}, {{{Null, Null}}}];
array = Flatten[Transpose /@ array, 1];
array = PadRight[#, Max[Length /@ array], Null] &  /@  array;
Export["data.xls", Transpose[array]]

Riffle puts the two empty columns between each of the lists. Flatten produces a list of the spreadsheet columns. PadRight makes each column the same length. The final transpose gives us a list of spreadsheet rows, which can be exported.

$\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.