joining rows

km srikrishnamohan at gmail.com
Sat Dec 29 06:53:12 EST 2007


Hi

On Dec 29, 2007 3:08 PM, Beema shafreen <beema.shafreen at gmail.com> wrote:

> hi every body,
>
>     I have two columns  in a file separted by tabs
>
> If the column1 is common  in the  row1 and row2  then it should  be column
> 2 should be displayed in the single line.
> eg:
> col 1     col2
> A            1
>  A            2
>  A            3
>  B            1
>   C           2
>   D           3
>   D           4
> The result should be
>
> A    1|2|3
> B    1
> C    2
> D    3|4
>
> What should I do to get my results
>
>
Looking at the answer u require , u can clearly make a  dictionary if list
datastructure!
where dictionary keys are A,B, C ,D  and corresponding values are  list if
items (ie., 1,2,3 ...)
Once u have such a dict loaded, its kust a matter of accessing that list via
a key and display it joined!
HTH
KM


>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071229/5910c3c9/attachment.html>


More information about the Python-list mailing list