[Tutor] Converting a string into dictionary references

Joel Goldstick joel.goldstick at gmail.com
Mon Apr 23 16:26:22 CEST 2012

On Mon, Apr 23, 2012 at 10:18 AM, nehal dattani <nehal.dattani at gmail.com> wrote:
> Hi,
>> Unfortunately I am not, this needs to happen in python.
> Please see if following helps.
> http://stackoverflow.com/questions/5863999/python-cut-example
> Regards,
> Nehal Dattani
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
Apparently I misunderstood.  I thought you might have been asking how
to convert the key strings  used in your 3rd file to make keys that
you could use to select only those columns you want to output.

But, now I think you are saying you want to select only certain
columns, and maybe change the order of the output.  Dicts don't have
an order, so you might be better off using the normal reader method
which returns a list.  Iterate over each row in your input dataset and
then use your output column list to do something like this:

So you could read the third file, and create a column_list = [1, 2, 3,
44, 22, ..] as appropriate.

 for r in in.csvreader():
   for c in column_list:
   write the line to the output file

Sorry for double reply.  I didn't reply all before
Joel Goldstick

More information about the Tutor mailing list