MathGroup Archive 2004

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

Search the Archive

Re: selecting columns from a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47874] Re: selecting columns from a list
  • From: "Curt Fischer" <crf3 at po.cwru.edu>
  • Date: Thu, 29 Apr 2004 03:05:56 -0400 (EDT)
  • References: <c6o4pc$clk$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Edo wrote:

> Hello
> I just started with mathematica, wanted to load a comma separated data
> file and drop the first two columns. So I did
> data=Import["C:\Data\filename.ext","CSV"]; to get the file into a
> variable "data", then I am stuck, after doing some reading in the help
> files about Drop, Partition, Take. ・瘢雹etc
> could someone tell me what to read and where to find info about
> indexing different data structures

It's all there in the Help Browser.  Look at the help for Part[].

Here's some simple ways of doing what you want.

In[1]:=
a={{1,2,3,4},{11,22,33,44},{111,222,333,444}}

Out[1]=
{{1,2,3,4},{11,22,33,44},{111,222,333,444}}

Use a replacement rule:

In[2]:=
a/.{x_,y_,z_,w_}\[Rule] {z,w}

Out[2]=
{{3,4},{33,44},{333,444}}

Or use Part[]:

In[3]:=
a[[All,{3,4}]]

Out[3]=
{{3,4},{33,44},{333,444}}

--
cf


  • Prev by Date: The Wave Equation : Mathematica vs. Mathworld
  • Next by Date: Re: selecting columns from a list
  • Previous by thread: Re: selecting columns from a list
  • Next by thread: RE: selecting columns from a list