On Fri, Jan 28, 2011 at 11:44 AM, Rich Shepard <[email protected]>wrote:

>  The goal of the exercise is to write an output .csv file suitable for
> import to a database table. This means concatenating row 0, column 1 with
> row 1, column 1 and row 2, column 0, row 2, column 1, row 3, col 0, row 3,
> col 1, etc. In other words, I want the output to look like this:
>
>
To get a list of the concatenated values for column 0, 1, 2... how about:

---

column_values = list()
for col in range(3):      # or whatever
    column_values.append(' '.join([row[col] for row in reader]))

---

If you have a very large amount of data, it might be worth the extra time to
do it in one pass... but the above might be good enough for the task at
hand.

HTH,

Dylan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.python.org/pipermail/portland/attachments/20110128/1c4a058b/attachment.html>
_______________________________________________
Portland mailing list
[email protected]
http://mail.python.org/mailman/listinfo/portland

Reply via email to