Vikram,<div><br><div> Do I understand the question? You have a particular dictionary, as such:</div><div><br></div><div><div>>>> x={'Protein Name': 'PE2R2_HUMAN', 'gi Number': '38258920', 'etc': 'blah'}</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>>>> print x.keys()</div><div>['etc', 'gi Number', 'Protein Name']</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'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"><<a href="mailto:kpguy1975@gmail.com">kpguy1975@gmail.com</a>></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 ('1A_out.csv','w')<br><br>
writer = csv.writer(fout)<br><br>writer.writerow(('Protein Name','gi Number', 'Peptide', 'Residue',<br>
'Position in Protein', 'length', 'Window''))<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(('Protein Name','gi Number', 'Peptide', 'Residue',<br>
'Position in Protein', 'length', 'Window''))<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>