Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16186 > unrolled thread

Re: Data format AFTER import into Mathematica from Excel.xls worksheet

Started byBill Rowe <readnews@sbcglobal.net>
First post2013-11-06 05:28 +0000
Last post2013-11-06 05:28 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Data format AFTER import into Mathematica from Excel.xls worksheet Bill Rowe <readnews@sbcglobal.net> - 2013-11-06 05:28 +0000

#16186 — Re: Data format AFTER import into Mathematica from Excel.xls worksheet

FromBill Rowe <readnews@sbcglobal.net>
Date2013-11-06 05:28 +0000
SubjectRe: Data format AFTER import into Mathematica from Excel.xls worksheet
Message-ID<l5ck2n$4ri$1@smc.vnet.net>
On 11/4/13 at 11:15 PM, nkormanik@gmail.com (nkormanik) wrote:

>I have a large Excel worksheet (200 columns, 4,000 rows).  Every
>column has a unique and carefully chosen title/label.

>I'm attempting to use it within Mathematica to create a large number
>of contour plots (1,000) -- using three columns at a time, for x, y,
>z.

>The import, I suppose, occurs.  At least it appears to have.

>Here's the question:

>-- Is Mathematica using my column titles, so that I can refer to
>them in commands subsequent to import?

No.

>-- If not, is there any format I can put my data into to begin with
>so that Mathematica will readily recognize my named columns?

Yes. But the specifics of how this can be done very much depends
on details of the labels you chose.

I accomplish what you seem to be trying to do by using labels
that are consistent with Mathematica's syntax for symbols. That
allows me to do something like

data=Join[{ToExpression[First@#]}, Rest@#]&@Import["file.xlsx"][[1]];

This imports the first worksheet, makes the first row of data a
list of symbols with all other rows as defined in the spread
sheet. Then I make use of this structure using a package I've
written for myself. To illustrate one of the functions:

In[4]:= data =
  Join[{{meas1, meas2}}, RandomReal[1, {5, 2}]]

Out[4]= {{meas1, meas2},
          {0.414328, 0.558225},
          {0.994564, 0.366895},
          {0.929041, 0.328639},
          {0.926444, 0.319253},
          {0.543304, 0.268241}}

In[5]:= AppendColumns[data, ratio, meas1/meas2]

Out[5]= {{meas1, meas2, ratio},
          {0.414328, 0.558225, 0.742223},
          {0.994564, 0.366895, 2.710759},
          {0.929041, 0.328639, 2.826929},
          {0.926444, 0.319253, 2.901913},
          {0.543304, 0.268241, 2.025431}}

If this is of interest to you, contact me off list and I will be
glad to send you the package. But do be aware, while I have
created usage messages so that I can recall what my intent was,
I have not created examples of how to use each function or
anything resembling user friendly documentation.

One other aspect of this package you might find too limiting. It
is specifically requires the first row to be symbols with no
assigned value. So, the labels cannot use a range of characters
you might otherwise use if the package were designed to use
strings rather than symbols as the column headers. I
specifically choose symbols rather than strings since I can
temporarily assign the values in each of the columns to the
symbols in the first row using Block and then use them in
arbitrary Mathematica expressions provided the functions in the
expressions all have the attribute Listable.




[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web