Vikram,<div><br><div>   Do I understand the question? You have a particular dictionary, as such:</div><div><br></div><div><div>&gt;&gt;&gt; x={&#39;Protein Name&#39;: &#39;PE2R2_HUMAN&#39;, &#39;gi Number&#39;: &#39;38258920&#39;, &#39;etc&#39;: &#39;blah&#39;}</div>
<div><br></div><div>And, you want to get the field names for printing in the header. </div><div><br></div><div>Is something like this helpful:</div><div><br></div><div>&gt;&gt;&gt; print x.keys()</div><div>[&#39;etc&#39;, &#39;gi Number&#39;, &#39;Protein Name&#39;]</div>
<div><br></div><div>(Notice that the order of these keys are not going to always be the same each time):</div><div><br></div><div><meta charset="utf-8">writer.writerow(x.keys())</div><div><br></div><div>If this isn&#39;t helpful, can you make a little snippet of code so that we can use that to define the problem.</div>
<div><br></div><div>Cheers,</div><div><br></div><div><br></div><div>Glen</div><div><br></div><br><div class="gmail_quote">On Tue, Feb 22, 2011 at 1:25 PM, Vikram K <span dir="ltr">&lt;<a href="mailto:kpguy1975@gmail.com">kpguy1975@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Consider the following python code which works perfectly:<br><br>fout = open (&#39;1A_out.csv&#39;,&#39;w&#39;)<br><br>
writer = csv.writer(fout)<br><br>writer.writerow((&#39;Protein Name&#39;,&#39;gi Number&#39;, &#39;Peptide&#39;, &#39;Residue&#39;,<br>

                 &#39;Position in Protein&#39;, &#39;length&#39;, &#39;Window&#39;&#39;))<br><br>I am writing the values in the csv file using a loop. Everything works fine.<br><br>Now in each row of the csv file i generated i need to append 36 values in 36 separate fields which i have captured in a dictionary data type. Will i have to write out all the extra 36 fields names in the following line or is there some better way?:<br>

<br>writer.writerow((&#39;Protein Name&#39;,&#39;gi Number&#39;, &#39;Peptide&#39;, &#39;Residue&#39;,<br>
                 &#39;Position in Protein&#39;, &#39;length&#39;, &#39;Window&#39;&#39;))<br><br>
<br><br>
<br>_______________________________________________<br>
Baypiggies mailing list<br>
<a href="mailto:Baypiggies@python.org">Baypiggies@python.org</a><br>
To change your subscription options or unsubscribe:<br>
<a href="http://mail.python.org/mailman/listinfo/baypiggies" target="_blank">http://mail.python.org/mailman/listinfo/baypiggies</a><br></blockquote></div><br><br clear="all"><br>-- <br><span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse">Things which matter most must never be at the mercy of things which matter least.</span><br>
<br>-- Goethe <br>
</div></div>