quote:
Originally posted by shyamigcar2
I have a large data something like the one below ---
35127 Malthonica
35127 MultiHance
35127 moldaenkei
35127 moldenkei
35127 multiunca
35130 homalodemus
35130 multihaemes
35131 meletimide
35131 multihamata
35131 multimoda
35132 muldamine
35132 omiltemana
35133 Melathemma
I wanted to arrange the data in such a way that a single row should contain all the words of the same number, ie., I wanted to avoid repeatation.
like for example
35127 Malthonica MultiHance moldaenkei moldenkei multiunca
35130 homalodemus multihaemes
35131 meletimide multihamata multimoda
35132 muldamine omiltemana Melathemma
It's quite simple in Python. Say there have been 4 columns, the first two containing the input data, the last two for the output data:
import PyOrigin as po
ns = po.Pages('Book1')[0][0].GetData() # data from the 1st column
ts = po.Pages('Book1')[0][1].GetData() # data from the 2nd column
keys, values = zip(*[[id,' '.join([ts[i] for i in range(len(ns)) if ns[i] == id])] for id in sorted(set(ns))])
po.Pages('Book1')[0][2].SetData(keys) # data to the 3rd column
po.Pages('Book1')[0][3].SetData(values) # data to the 4th column
#####
#### _\_ ________
##=-[.].]| \
#( _\ | |------|
# __| | ||||||||
\ _/ | ||||||||
.--'--'-. | | ____ |
/ __ `|__|[o__o]|
_(____nm_______ /____\____