The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 words rearrangement

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
shyamigcar2 Posted - 06/06/2017 : 11:36:35 AM
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



3   L A T E S T    R E P L I E S    (Newest First)
Castiel Posted - 06/15/2017 : 8:58:49 PM
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_______ /____\____ 
Hideo Fujii Posted - 06/07/2017 : 3:01:44 PM
Hi shyamigcar2,

To output the combined strings into a single cell, as Snow said for now there is no straightforward option to do.
For now as a work-around, you can try a script like:
string chain$;
nr=wks.maxRows;  //number of rows
for(ii=1; ii<=nr; ii++) {
  col(C)[ii]$="";  //empty cell temporarily
  if(ii==1) chain$=col(B)[ii]$;  //initial chain of 1st row
  else {
    if(col(A)[ii]!=col(A)[ii-1] || ii==nr) {  //if found new value, or at bottom
      if(ii<nr) {  //not at bottom
        col(C)[ii-1]$=chain$;  //output chain to previous cell
        chain$=col(B)[ii]$;    //reset chain
      }
      else  col(C)[ii]$=chain$+", "+col(B)[ii]$; //at bottom
    }
    else chain$=chain$+", "+col(B)[ii]$;  //chain grows
  }  
}
Hope this helps.

--Hideo Fujii
OriginLab
snowli Posted - 06/06/2017 : 5:32:24 PM
Hello,

After arrangement, do you expect all those text in same column or differnent columns?

E.g. do you expect "Malthonica MultiHance moldaenkei moldenkei multiunca" in one cell, separated by space?
Or you expect them to show in one row but different columns.

For latter, here is a workaround.
Highlight column B and choose Worksheet: Unstack Columns and choose column A as Group column.
This will reorganize the data so all text with same column A value will be in same column.
Then choose Worksheet: Transpose... menu to transpose the data.
In the dialog, set Output Worksheet as new sheet.
Set Recalculation Mode to Auto.
Set Label Type as Comment support in Unstacked sheet, 35127, .... shows in Comments row.
Click OK.

In each dialog, you can choose the > button next to Dialog Theme and choose Generate Script. It will dump the corresponding Script u can use to execute the rearrangement.

If you want all of them in one cell, we don't support it yet, but we can add an option in Remove/Combine Duplicated Rows tool.

Thanks, Snow



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000