MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Export list to Excel without brackets

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122475] Re: Export list to Excel without brackets
  • From: A Retey <awnl at gmx-topmail.de>
  • Date: Sat, 29 Oct 2011 07:13:23 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j7jorq$8nq$1@smc.vnet.net> <j7m5kl$jkp$1@smc.vnet.net> <j8dt75$kdn$1@smc.vnet.net>

Hi,

>>
>> One simple way is this:
>>
>> list={{{1.27,1.12,1.00,0.90,0.83},{0.27,0.12,0.00,-0.10,-0.17},
>>       {0.66,0.56,0.49,0.43,0.38},{0.72,0.57,0.49,0.44,0.42}},
>>       {{1.09,1.03,0.97,0.93,0.89},{0.09,0.03,-0.03,-0.07,-0.11},
>>       {0.27,0.25,0.23,0.21,0.20},{0.29,0.25,0.23,0.22,0.23}}};
>>
>> Export["c:\\temp\\list.csv",Insert[Flatten[Map[Transpose,list],1],{},
>> 6]];
>> Run["startexcelc:\\temp\\list.csv"];
>
> Very helpful, thank you! This works well until I try to write to a
> filename whose path name contains spaces. Any suggestions?

what is going wrong? I think that the export should work with spaces in 
the name alright. On the other hand you will need an extra pair of "" 
for the Run statement, which must be escaped e.g.:

Run["start excel \"C:\\Users\\albert.retey\\Desktop\\tst 2.xls\""]

Note that you could just as well save to xls format instead of csv, once 
you have restructured your list to represent the array you want to export.

Here is another version for that restructuring, which should work for a 
list with arbitrary many arrays of arbitrary dimensions. It inserts an 
empty row between all arrays and then "flattens" by replacing List with 
seq and then seq with Sequence:

data = Block[{seq},
   Riffle[seq @@@ (Transpose /@ list), {}] /. seq -> Sequence]

hth,

albert




  • Prev by Date: Re: Coin Toss Sim
  • Next by Date: Re: List plot with random size for each point
  • Previous by thread: Re: Export list to Excel without brackets
  • Next by thread: Receive e-mails with Mathematica 8