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
 Origin Forum
 Naming for convert to matrix + header skipping...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

jdf726

78 Posts

Posted - 05/05/2017 :  12:10:50 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): Origin 2015 and 2016 32 and 64 bit
Operating System: Windows 7

I do a LOT of repetitive processes in Origin and I'd like to understand where I can trim a few of these down. I feel sure that some of these can be simplified with the GUI (or if I have to with an OriginC function). I am losing days and days of my life with this stuff... ;-)

1) Convert direct from worksheet to matrix...transfering copying workbook name!
If I import some data (say I drag a tdms file with 2D data in, or I import 2d ASCII to a worksheet) I often need to make a matrix, but it ends up in an 'anonymous' <new> Matrix. How do I copy the workbook name across to the matrix? (I normally paste the old name to the matrix by hand afterwards....or just get confused about which matrix is which!)

2) Can I set graphs to have scaling = 1 by default? (I have to set this EVERY time I plot a graph). Perhaps if I messed with the graph templates (is the display scaling stored in the template?)

3) The import ASCII function looks pretty sophisticated but I cannot get it to skip a header of variable length - The start of my data is demarked by a blank line - can I get it to skip the header to this point? (I am guessing I have to write an originc function if this not an option on the importer).

I can probably think of about ten other things, but I'll leave it at that.

Cheers

jdf726

arstern

USA
237 Posts

Posted - 05/05/2017 :  1:18:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello

1) To input the name of the worksheet into the matrix:
When you select convert to matrix. In the convert to Matrix Dialog box, you can input a name that you would like to specify for the Matrix in the Output Matrix dialog box.



2) To create graph settings that will be applied every time you graph, you can create a Graph Template. After creating a graph with the applied settings, you can save the graph as a template to reuse when plotting with other data. See links below:

http://www.originlab.com/index.aspx?go=Products/Origin/Graphing&ss=chm&pid=1167

www.originlab.com/doc/Origin-Help/Graph-Template-Basics

3)You will want to use Import Wizard, rather than import ASCII. In the Import Wizard you can select the number of main header lines and number of subheader lines. In the Header Lines page of the Import Wizard, if you unselect auto determine header lines you can edit the number of subheader lines, this will remove a line. You will be able to see what is removed in the displayed white box (Please let me know if I misunderstood your question, maybe provide a picture).

Thanks,
Aviel
OriginLab
Go to Top of Page

jdf726

78 Posts

Posted - 05/05/2017 :  1:50:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for getting back to me so quickly!

For issue 1) Say I drag and drop 4 files that I have exported to ascii from Labview. Each is called some identifiable name '34F72.dat' or whatever. Each needs to be converted to a matrix with the corresponding name. I can do this with the GUI and type in/paste a name for each, but this is a pain when the name of the data is already stored as the worksheet name.
In the 'export graphics' dialog you can use a kind of 'substitution notation' to refer to the present project path. There you can you export to a location relative to the present project folder, and the name of the exported file is the name of the graph you are exporting. That works well! But the default output in the matrix conversion name field is <new>. It would be great if it was something like <sourceworksheetname>, or whatever. Once upon a time I think I had a labtalk script that might have done this automatically...

For 2) it seems to be true that I can save the display scaling with a template, so as long as I create the plot with that template, it should be asserted. Can I apply a template to an already plotted graph (I looked for something like 'apply template', but I can only see 'save..').

For issue 3) I I can manually specify the number of header lines to skip using the wizard. The trouble is that my data doesn't always have the same number of header lines. I hoped that the 'blank line before start of main data' structure was well-defined enough that I could get the importer to use this to auto-skip to this point, but the automatic header identification does not work for my data (the header data format like an INI file, with colon separated name:value clusters wrapped in braces with terminating semi-colons), but I just tested it on simpler data set and it worked. What exactly is the algorithm for skipping the header?!

jdf726
Go to Top of Page

arstern

USA
237 Posts

Posted - 05/05/2017 :  4:40:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

1) In Labtalk an example script that you can use is:
w2m iw:=[Book3]Sheet1! om:=[MBook1]MSheet1;

w2m function is a function for transferring data from worksheet to matrix
iw:=[Book3]Sheet1! describes changing the worksheet Book3 to a matrix
om:=[MBook1]MSheet1; creates the name of the matrix book and sheet.

For more information on using labtalk to create a matrix from worksheet:
http://www.originlab.com/doc/X-Function/ref/w2m

example:
http://www.originlab.com/doc/LabTalk/guide/Converting-Worksheet-to-Matrix

2) You can apply the Scaling to a graph by using the Theme Organizer. Open the Theme Organizer from the tools tab (or select F7). Under the Graph tab there is an option for Layer No Element Scaling. Select the graph you wish to apply this setting to and select Apply Now.

For future graphs, if you want to plot with this setting, right click Layer No Element Scaling and select Set as System Theme. Then when you plot, this theme will apply.



3) In Import Wizard and Import ASCII if you select Auto Determine Subheader lines and keep Number of Main Header lines as 0, then when uploading files, the variation in your Header should not matter. It should skip the header for all files, and only list your subheaders.



See example below:


Thanks,
Aviel
OriginLab
Go to Top of Page

jdf726

78 Posts

Posted - 05/05/2017 :  5:48:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks again for your reponses.

1) Great! - this must be the Labtalk way I remember I tried. You can control the X- or Y- scaling with some other arguments I think.
2) Great also - I haven't use 'themes' before so that dialog was unfamiliar to me, thanks.

3) I found I still could not import data consistently - for very long test headers (e.g. the word 'test' 100 times as header lines, one blank line and then three cols of 15 integers) it gives me an error message "File "test.dat" is invalid!".
Then for my actual data it stops at line 19 and I think it starts importing the header as data (this is what I have seen previously).
BUT...I think I fixed this by setting the "Max number of Consistent lines..." number to 1000...
In the 'help file' it says that I should set this to be less than the file length, but longer than the header - I really hope that this is not strictly necessary because generally I don't know (without checking) what this could be (the headers is 100-400 lines long and my data ~1-1000).

I have two follow up questions:
Can I capture the skipped header as a lump of text with the data ?
Running "impasc" doesn't seem to load the theme I saved as 'default'? (the one with the above settings)
Any ideas?


jdf726

Go to Top of Page

jdf726

78 Posts

Posted - 05/06/2017 :  06:51:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
To partly answer my own question...

To run the 'import ascii' with a predefined theme (because default doesn't seem to load by default for me).

impasc –t “mytheme”

I tried to work out how to stop the import options dialog from ever appearing. If you use the dlgFile with the multiple file option then call impASC it magically passes the filelist via some invisible predefined background variable (confusing!).

dlgFile m:=1 g:="*.*"; impASC -t "mytheme"

I also used the 'generate script' GUI option (which is nice!) to set the options for impasc without using themes at all.

You can run this within an originC function (calling the labtalk via the LT_execute command).

string strScript;
strScript.Format("impASC options.FileStruct.NumericSeparator:=0 options.Cols.MaxTestLns:=1000 options.Cols.ColDesign:=<Unchanged> options.Hdr.LNames:=0 options.Hdr.Units:=0 options.Hdr.CommsFrom:=0 orng:=[%s] fname:=\"%s\"", filename,filepath);
LT_execute(strScript);

Its a pain that there are so many layers of syntax here - this uses a string subtitution to pass the OC filename arguments into the labtalk 'script' that I wanted to execute. And don't forget to escape the quotes!!!

If there was a side by side comparison of how to call the originc and labtalk versions this would help.
I was greatly assisted in the labtalk version with the GUI 'generate script' option, but to set the options for the origin C version I have to dig in the documentation on how to set the options via the 'ASCIMP' type which does not have precisely the same syntax (options.Cols.MaxTestLns becomes ai.iMaxTestLines, assuming you have declared a variable 'ai' of type ASCIMP).

http://www.originlab.com/doc/OriginC/examples/Import-ASCII
http://www.originlab.com/doc/OriginC/ref/ASCIMP



jdf726
Go to Top of Page

jdf726

78 Posts

Posted - 05/08/2017 :  12:59:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Workbook to matrix, while copying name

a$ = page.longname$; w2m -r 0 xy:=xcol xlabel:=row1 ycol:=1 om:=a$

(you have to swap to something like xy:=ycol and ylabel=row1 and xcol:=1 to import the other way round)

You can do the reverse with m2w.

a$ = page.longname$; m2w -r 2 ycol:=1 xlabel:=row1 ow:=[a$]!a$

Maybe I should put this into some toolbar buttons so I don't have to remember it (I know there are several ways to execute labtalk code).

Edited by - jdf726 on 05/08/2017 1:02:58 PM
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