MathGroup Archive 2007

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

Search the Archive

Re: Copy and Pasting Tables into Spreadsheet

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83368] Re: Copy and Pasting Tables into Spreadsheet
  • From: Bill Rowe <readnewsciv at sbcglobal.net>
  • Date: Sun, 18 Nov 2007 04:53:47 -0500 (EST)

On 11/17/07 at 5:35 AM, gregory.lypny at videotron.ca (Gregory Lypny)
wrote:

>I don't understand why I cannot use the Copy As menu item and copy a
>table's contents as plain text and paste directly into a
>spreadsheet. It works nicely for some tables but not others.
>Likewise, exporting a numeric table to a text file as "CSV" or "TSV"
>often gives me the table as a string with the curly list brackets as
>delimiters rather than commas or tabs (see below).

>Is there any way to get tables into a spreadsheet easily?  Should I
>be using Do loops instead?

If you are going to use either "CSV" or "TSV" formats as a
bridge between Mathematica and spreadsheets, your data will have
a Depth of no more than 3.

For the data you gave (which is missing a set of brackets):

>{{0.45454545454545453}},{{0.47116258460171057}},
>{{0.48753220003368414}},{{0.5036695259640319}},{{0.5195882049828201}
>},
>{{0.5353005230127573}},{{0.5508175949010553}},{{0.5661495182384557}}
>

data = {{{0.45454545454545453}}, {{0.47116258460171057}}, \
{{0.48753220003368414}}, {{0.5036695259640319}}, \
{{0.5195882049828201}}, {{0.5353005230127573}}, \
{{0.5508175949010553}}, {{0.5661495182384557}}};

In[3]:= Depth@data

Out[3]= 4

and

In[4]:= MatrixQ@data

Out[4]= False

This can be corrected using Flatten, i.e.,

In[5]:= Depth@Flatten[data, 1]

Out[5]= 3

and

In[6]:= MatrixQ@Flatten[data, 1]

Out[6]= True

That is Export[filename, Flatten[data,1],"CSV"]

will do what you want.

But you should be aware Mathematica can write directly to native
Excel files, i.e.,

Export[filename, Flatten[data,1], "XLS"] will result in a
standard Excel file

When exporting to "XLS" format the Depth can be as high as 4. A
Depth of 4 will cause multiple worksheets to be created.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Creating a Slideshow with Mathematica6!
  • Next by Date: Re: Trouble with Rotate
  • Previous by thread: Re: Copy and Pasting Tables into Spreadsheet
  • Next by thread: Re: Copy and Pasting Tables into Spreadsheet