[Baypiggies] csv module question

Glen Jarvis glen at glenjarvis.com
Tue Feb 22 23:03:54 CET 2011


   Do I understand the question? You have a particular dictionary, as such:

>>> x={'Protein Name': 'PE2R2_HUMAN', 'gi Number': '38258920', 'etc':

And, you want to get the field names for printing in the header.

Is something like this helpful:

>>> print x.keys()
['etc', 'gi Number', 'Protein Name']

(Notice that the order of these keys are not going to always be the same
each time):


If this isn't helpful, can you make a little snippet of code so that we can
use that to define the problem.



On Tue, Feb 22, 2011 at 1:25 PM, Vikram K <kpguy1975 at gmail.com> wrote:

> Consider the following python code which works perfectly:
> fout = open ('1A_out.csv','w')
> writer = csv.writer(fout)
> writer.writerow(('Protein Name','gi Number', 'Peptide', 'Residue',
>                  'Position in Protein', 'length', 'Window''))
> I am writing the values in the csv file using a loop. Everything works
> fine.
> 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?:
> writer.writerow(('Protein Name','gi Number', 'Peptide', 'Residue',
>                  'Position in Protein', 'length', 'Window''))
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies

Things which matter most must never be at the mercy of things which matter

-- Goethe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20110222/7414917e/attachment.html>

More information about the Baypiggies mailing list