Re: Data format AFTER import into Mathematica from Excel.xls worksheet
- To: mathgroup at smc.vnet.net
- Subject: [mg131959] Re: Data format AFTER import into Mathematica from Excel.xls worksheet
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Wed, 6 Nov 2013 00:36:44 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
On 11/4/13 at 11:15 PM, nkormanik at 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.