<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 12/10/2011 18:21, Anna Olofsson wrote:
<blockquote cite="mid:SNT109-W1286C70B0A0A6BDC4AD660A3E30@phx.gbl"
type="cite">
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
<div dir="ltr">
Hi,<br>
<br>
I'm a beginner at python and I'm trying to extract a specific
column from a txt file ( see attached file). <br>
<br>
In the attached file I want to extract the entire column<i>
pph2_prob </i>(i.e. column 16). But I want to get all the
values from that column without the headline <i> pph2_prob.<br>
<br>
</i>How do I accomplish that? <br>
<br>
Best,<br>
Anna<br>
</div>
<br>
</blockquote>
<br>
<br>
Dear Anna,<br>
<br>
Using the CSV module should work.<br>
<br>
Something along the lines of (untested):<br>
<br>
inLines = CSV.DictReader("/path/to/myfile.csv")<br>
data = []<br>
for a in inLines:<br>
data.append(a)<br>
<br>
for line in data:<br>
print line["<i>pph2_prob</i>"]<br>
<br>
<br>
Once you've got that working you just need to put the results in a
file, instead of printing them.<br>
<br>
On a practical note (and there may be many reasons why not to), it
might be easier to open in a spreadsheet and take the data from
there....<br>
<br>
HTH,<br>
<br>
Matt<br>
</body>
</html>