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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 words rearrangement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

shyamigcar2

India
25 Posts

Posted - 06/06/2017 :  11:36:35 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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



snowli

USA
1384 Posts

Posted - 06/06/2017 :  5:32:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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


Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 06/07/2017 :  3:01:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Castiel

343 Posts

Posted - 06/15/2017 :  8:58:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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_______ /____\____ 
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000