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
 removing columns and rows
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

DanieleOrigin

Italy
7 Posts

Posted - 12/01/2015 :  08:46:38 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi to everyone!
i'm trying to make some ripetitive processes automatic with labtalk. i attached my file in photos.
what i want to automatize is:
-duplicate in an other sheet
in the new sheet i want
-removal of the columns A, B, E, F, G
-removal of the rows from 1 to 2247 and the row called Sparklines (that is in yellow)
-substitute a group of yellow cell with new fields (as you can see in the second photo)
-confirm the operation with a pop-up mask

i've tried to automatise but i just managed to removed the columns.
can someone please help me, writing here the command i have to write?
thanks in advance and sorry for my bad english.


RAW FILE
http://www.originlab.com/ftp/forum_and_kbase/Images/Cattura5.PNG" border="0">

kfauth

Germany
33 Posts

Posted - 12/02/2015 :  05:13:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I would like to think that at least partially (if not all) can be done directly when importing. If you use the ASCII import wizard, then you can set it up to do what you want. Especially, you can get rid of the header information and you can deselect the automatic creation of sparklines. Whether you can do a partial import (starting from some specified row) -- I am almost sure you can configure that, too.
Go to Top of Page

DanieleOrigin

Italy
7 Posts

Posted - 12/02/2015 :  12:30:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You are right but I need to keep the original data in a sheet and the elaborated data in a second sheet (unfortunately).
If someone can help me in doing this, it will be wonderful.
Go to Top of Page

SeanMao

China
288 Posts

Posted - 12/03/2015 :  01:17:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

The LabTalk command is as following:


wcopy 1! 2!; // Duplicate 1st sheet to 2nd sheet
range r1 = (col(a),col(b),col(e),col(f),col(g)); 
delete r1; // Delete A, B, E, F, G
wks.deleteRows(1, 2247); // Remove row 1 to row 2247
wks.labels(-S); // Remove Sparkline
col(C)[L]$ = "E vs SCE"; // Label columns
col(D)[L]$ = "I";
col(C)[U]$ = "v";
col(D)[U]$ = "A/cm2";
wks.addcol(Log); // Add new column 
csetvalue col:=col(Log) formula:="log(abs(col(D)))"; // Set Column Formula


Just copy and paste it in Script Window and hit Enter to run.

Regards!

Sean

OriginLab Tech.
Go to Top of Page

DanieleOrigin

Italy
7 Posts

Posted - 12/03/2015 :  05:14:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thanks a lot SeanMao!!
it is almost perfect, but i have problem with rows: when i start the labtalk script, i don't know why the program doesn't remove the rows.
other commands are perfect.
can you please help me?
i'm running origin 9.2
Go to Top of Page

SeanMao

China
288 Posts

Posted - 12/04/2015 :  04:36:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Sorry that I just found out this wks.deleterows() function is Origin 2016 SR0 new feature.

You can try:



range r2 = col(C)[1]:col(D)[2247];
delete r2;



Regards!

Sean

Edited by - SeanMao on 12/04/2015 04:37:05 AM
Go to Top of Page

DanieleOrigin

Italy
7 Posts

Posted - 12/04/2015 :  2:08:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
you are the best, dear sean!
thank you very much! it will change my work and the work of my team.
then, just one more thing...
-how can i obtain a final pop-up mask (to confirm to my team that the labtalk procedure has done properly)?
-how to duplicate the sheet mantaining the same name (instead of "Sheet 1")?
thanks in the name of whole my team.
Go to Top of Page

SeanMao

China
288 Posts

Posted - 12/06/2015 :  9:14:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Q1:

type -b "Data manipulation is done!"; // Display a dialog with text


You can put this line at the end of data manipulation.

Q2:
string strSht$ = wks.name$+"_1";
wcopy 1! [%H]%(strSht$)!;


Just replace the wcopy 1! 2! to the code above. This will add "_1" to the sheet name of 1st one since it is forbidden to have two sheet the same name.

Regards!

Sean

OriginLab Tech.


Go to Top of Page

DanieleOrigin

Italy
7 Posts

Posted - 12/08/2015 :  6:20:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sean you are a boss!
the routine now is perfect, the only out-of-order command is

string strSht$ = wks.name$+"_1";
wcopy 1! [%H]%(strSht$)!;

in the place of

wcopy 1! 2!; // Duplicate 1st sheet to 2nd sheet

because when i use it, the new sheet (the duplicated one) has the name "0" and it is blank (it has just the yellow labels filled).
anyway you help us!
thanks a lot!

Daniele
Go to Top of Page

SeanMao

China
288 Posts

Posted - 12/08/2015 :  9:22:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Try to replace the wcopy 1! 2! command line with:


string strSht$ = wks.name$+"_1";
wcopy 1! 2!;
wks.name$=strSht$;


The short name of your sheet contains spaces so it does not work at first.

Regards!

Sean
Go to Top of Page

DanieleOrigin

Italy
7 Posts

Posted - 12/09/2015 :  05:47:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks! My team is really enthusiast!

they ask me another question: is it possibile to add automatic plot?
i managed to obtain a plot looking on the site with
plotxy iy:=(3,1) plot:=200;
but how can i obtain that plot with the same name of the worksheet it come from? (for example worksheetname+1 instead of Graph1, i haven't find a solution)
thanks for time you have been dedicating to us!

regards

Edited by - DanieleOrigin on 12/09/2015 10:04:52 AM
Go to Top of Page

SeanMao

China
288 Posts

Posted - 12/09/2015 :  10:05:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

After plotxy command line, add these two lines:


page.title=1; // Change window to display Long Name
page.longname$ = strSht$; // Set Long Name


Regards!

Sean

OriginLab Tech.
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