RE: selecting columns from a list

• To: mathgroup at smc.vnet.net
• Subject: [mg47876] RE: [mg47844] selecting columns from a list
• From: David.Annetts at csiro.au
• Date: Thu, 29 Apr 2004 03:06:03 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Edo,

> 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
> different data structures

Both the online help (Part is the section you're after) and Ruskeepaa's
book are good places to start.

Given the commands to load the file ...

SetDirectory["c:/tmpfiles"]
csv = Import["2101.csv", "CSV"];

This reads data into an array.  We can get an element of this array
using
line05col06 = csv[[5, 6]]

The first line is given by
l01 = csv[[1]] (or First[csv])

The first column, by
c01 = #[[1]] & /@ csv

The 5th column by
c05 = #[[5]] & /@ csv

We can take a combination using
crd = Take[csv[[#]], {4, 6}] & /@ Range[Length@csv]
In the last case, I've taken columns 4, 5 & 6 from each line in the
file.

Regards,

Dave.
==========================================
Dr. David Annetts
EM Modelling Analyst
CSIRO DEM            Tel: +612 9490 5416
North Ryde           Fax: +612 9490 5467
Australia         David.Annetts at csiro.au
===========================================

```

• Prev by Date: Re: Problem With "Copy Input from Above"
• Next by Date: Re: Re: Matrix Expansion question to Mathgroup
• Previous by thread: Re: selecting columns from a list
• Next by thread: \$Path Management.