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
 Import script help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ghuoof

New Zealand
5 Posts

Posted - 11/06/2015 :  05:56:49 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: 9.0.0 SR2
Operating System: Win 7 32 bit

Hi,

I want to write an import script which will duplicate the sheet and transpose it basically. I want the first column to come from the comments.

I have gotten as far as duplicating the sheet...
worksheet -dr transposed;      //duplicate sheet and make it active


simple things like this don't seem to do anything:
wks.insertRows(1);


but others do:
col(B)[L]$ = "TEST";


help?

jasonzhao

China
262 Posts

Posted - 11/08/2015 :  8:48:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

You can define an import Theme with name 'Userdef', which specifies using which column as the 'Comment';


Then, we apply this theme in the LabTalk Script:


string fn$=system.path.program$ + "Samples\Curve Fitting\Ellipse.dat"; 

impasc fname:=fn$ -t "Userdef";


Best regards!
Jason
OriginLab Technical Service

Edited by - jasonzhao on 11/08/2015 8:50:58 PM
Go to Top of Page

ghuoof

New Zealand
5 Posts

Posted - 11/10/2015 :  03:58:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Right, thanks.

I think I did a poor job of explaining what I want to do. I already have an import filter set up but I want each file I import to create two sheets or books. One which will be a transpose of the other. The comments row from the non-transposed sheet should be part of that block that gets transposed, if that makes any sense. So it should become a column and vice versa.

quote:
Originally posted by jasonzhao

Hello,

You can define an import Theme with name 'Userdef', which specifies using which column as the 'Comment';


Then, we apply this theme in the LabTalk Script:


string fn$=system.path.program$ + "Samples\Curve Fitting\Ellipse.dat"; 

impasc fname:=fn$ -t "Userdef";


Best regards!
Jason
OriginLab Technical Service

Go to Top of Page

jasonzhao

China
262 Posts

Posted - 11/10/2015 :  04:26:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

You can use the wtranspose X-function to transpose the worksheet with 'Comment' row.
http://www.originlab.com/doc/X-Function/ref/wtranspose

For example, you can active the sheet, and run the Script:

wtranspose type:=comment ow:=<new>; 

Then, new created transposed sheet will use comments as 1st column.


Best regards!
Jason
OriginLab Technical Service
Go to Top of Page

ghuoof

New Zealand
5 Posts

Posted - 11/10/2015 :  4:39:16 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks! That works, it's almost what I want. Can I likewise have the first column transposed to the comments somehow?
Go to Top of Page

jasonzhao

China
262 Posts

Posted - 11/11/2015 :  03:57:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

To use the 1st column as the comment after transpose, plese try the script below:


wtranspose type:=comment col:=first ow:=<new>;


Best regards!
Jason
OriginLab Technical Service
Go to Top of Page

ghuoof

New Zealand
5 Posts

Posted - 11/11/2015 :  04:51:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Jason, that works perfectly. Thanks for your help and quick replies.

I just wanted to say that I think origin is great and really powerful but the documentation is quite confusing. Having a few more examples would be quite helpful. I have a bit of programming experience but I don't think I would have figured out how to use wtranspose correctly from reading this description of col:=first:

"Exchanges the first data column with the selected column label row with X column designation. The Label Type cannot be Sample Rate. Note: the leftmost cell of the column label row will be excluded in the exchange."
Go to Top of Page

jasonzhao

China
262 Posts

Posted - 11/12/2015 :  04:54:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the comment.
We will add some examples.

One thing that might help you in programming is that we can generate script from the dialog. For example, in this case, you can

1. Choose menu Worksheet: Transpose (or run "wtranspose -d")
2. In the opened dialog, set setting as you want
3. Click on the triangle button next to the Dialog Theme and choose Generate Script from the context menu
-->The script for using the settings in the dialog will be output to the Script Window, then you can use it in your programming






Best regards!
Jason
OriginLab Technical Service

Edited by - jasonzhao on 11/12/2015 04:55:05 AM
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