[Date Index]
[Thread Index]
[Author Index]
Re: How Import data from Excel and make a list of numbers
*To*: mathgroup at smc.vnet.net
*Subject*: [mg82163] Re: How Import data from Excel and make a list of numbers
*From*: Bill Rowe <readnewsciv at sbcglobal.net>
*Date*: Sat, 13 Oct 2007 04:01:11 -0400 (EDT)
On 10/12/07 at 2:57 AM, dinodeblasio at gmail.com wrote:
>How I can import in Mathematica 6 data from Excel? More in details,
>how i can trasform a list of numbers present in one excel columns->
>to one list of numbers in Mathematica 6 in the form:
>{1,2,3,4,5,........}
You import Excel files with
data = Import[filename, "XLS"];
Assuming there is one Excel worksheet, you can get a specific
column by doing
col = data[[All,n]] where n is the column number. Or you could
combine these into one line by doing
col = Import[[filename][[All,n]];
Note, this assumes all rows in that worksheet have at least n
columns. That is if the worksheet has the form
comment
blank row
blank row
a1 a2 a3 ...
b1 b2 b3 ...
...
you will get an error doing
Import[filename,"XLS"][[All,3]]
since the first few rows have fewer than three columns. In this
case, getting the third column of the data array could be done using
col = Cases[Import[filename,"XLS"],_?(Length>3#)][[All,3]]
Of course, if you didn't create the Excel file and don't have
something that will display the structure of the file, you have
no way to know what that structure will be. What I do in those
cases is simply
data = Import[filename, "XLS"];
then use commands like Dimension, Depth, Length etc to determine
the structure. Once that is know, it is a simple matter to
extract a particular column using Part, Span etc.
--
To reply via email subtract one hundred and four
Prev by Date:
**Re: How to do count for sub list?????**
Next by Date:
**Inset a 3D Graphic**
Previous by thread:
**How Import data from Excel and make a list of numbers**
Next by thread:
**Hiding Input Cells**
| |