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
 Table-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

chessboard12

10 Posts

Posted - 01/25/2019 :  10:43:27 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 2018G (64Bit)
Operating System: Windows 10

Hello everyone,

it`s me with the same question again: i try to split a huge table.
yuki wu gave me some help, but the division of the table was at the wrong positions.
Nevertheless thank you for this response! :)

So, to better depict the problem here`s a picture of the current table:



The marked "H"s in the first column indicate a new measurement series. These series are all listed below themselves.
To better compare the data all measurement series should be arranged next to each other and in one worksheet.

After rearrangement it should look like this:




The measurement series are differently long, so splitting every 100 rows will not work. It´s only the letter "H" which indicates the start of a new measurement series.

Further more it would be helpful to delete columns "A" and "D" of the current table and illustrate column B (date) only once.


Thanks in advance, yuki wu, if you could give me some additional help for that! And of course thanks to everyone else! :)

Ben

yuki_wu

896 Posts

Posted - 01/27/2019 :  9:52:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

Hi Ben,

If you don’t want to split the data into several worksheets, you could unstack columns instead. I added comments in the script I told you before, I think it will be easier to understand now:

wks.addCol("Group"); //Add a new column to store the group index
range rA = col(1);
int nRows = rA.GetSize(); //Get the rows number of column(1)
range rG = col($(wks.nCols));
int nGroup = 0;
string str$ = "H*"; //If the indicator is exactly "H", you could modify this line to string str$ = "H";
for(int ii = 1; ii <= nRows; ii++) //Loop over column(1)
{
	if(Match(rA[$(ii)]$, str$))//To check if col(1)[ii] starts with the character "H"
	{
		nGroup++;
	}
	rG[$(ii)] = nGroup; //Fill the group index in col("Group")
}
//wsplit -r 2 mode:=ref ref:=col($(wks.nCols)); //Split the grouped data into several worksheet
//Modify irng1 according to your source data
wunstackcol irng1:=(2:5) irng2:=6; //Unstack the grouped data, more info: https://www.originlab.com/doc/X-Function/ref/wunstackcol







Regards,
Yuki

OriginLab
Go to Top of Page

chessboard12

10 Posts

Posted - 01/28/2019 :  07:43:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi yuki wu,

wks.addCol("Group") does not work, so that there`s no 6th column which displays the group index.

In your examples this "group index column" is already present in the beginning picture. How`s that?

Regards,
Ben
Go to Top of Page

yuki_wu

896 Posts

Posted - 01/28/2019 :  9:16:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I didn't create the grouped index column by manual, it was created by wks.addCol() and later fill the value by script I showed you. This image may help you understand it:


https://www.originlab.com/doc/LabTalk/ref/Wks-obj

Regards,
Yuki

OriginLab
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