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
 All Forums
 Origin Forum
 Origin Forum
 Scripting: Load Files and changes on the Worksheet

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
mattse123 Posted - 11/07/2017 : 06:07:44 AM
Hey, i just got a brief question about an issue i did not find an answer after around 2 days of searching in origin-forums.

The Situation is the following: I work in the field of organic photovoltaics, where i generate multiple measurement files.
I want to automatically import the files into one worksheet - for the first file, the first and the second column should be imported as x and y values.
For all following files, only the second column should be imported as y-values.
I did already succeed with that, using the following Code:



string fns, path$ = "C:\Users\myname\Desktop\OriginTest\"; 
	findfiles f:=fns$ ext:="*.dat";
	int numFiles = fns.GetNumTokens(LF);

	
	for(int ifile = 1; ifile <= numFiles; ifile++){
		
		if(ifile==1){
			string strToken$ = fns.GetToken(ifile)$;
			strToken$=;
			impasc fname:=strToken$ 
			
			options.PartImp.Partial:=0
			options.PartImp.FirstCol:=2
			options.Sparklines:=0
			options.Names.AutoNames:=0
			options.Names.FNameToSht:=1
			options.ImpMode:=1
			options.Miscellaneous.LeadingZeros:=1;
	
		}
		
		else if(ifile>1){
			string strToken$ = fns.GetToken(ifile)$;
			strToken$=;
			impasc fname:=strToken$ 
			
			options.PartImp.Partial:=1
			options.PartImp.FirstCol:=2
			options.Sparklines:=0
			options.Names.AutoNames:=0
			options.Names.FNameToSht:=1
			options.ImpMode:=1
			options.Miscellaneous.LeadingZeros:=1;
	
		}
		
	}


The problem i have now is the following: I want to import only the rows until let's say the last row minus 10 rows. How can i find out how many rows my worksheet has? I only found out the worksheet-commands like:


WorksheetPage wp;
wp.Create("Origin");
	
	
	Worksheet wks(wp.Layers(0));
	
	int nRows = wks.GetNumRows();


But when i simply use the impASC-command, i don't have a worksheet-object to work on. Can i internally cast the imported data to a worksheet-object, so to use the GetNumRows()-command on it?

________________

I hope i explained my Problem in an understandable manner. Thank you for your help in advance.
3   L A T E S T    R E P L I E S    (Newest First)
mattse123 Posted - 11/09/2017 : 06:45:23 AM
Hey there, i tried to acces an element in an array now with the syntax:



double temp2 =%(col(2)[50]$);



which shows me the entry at this position in the current worksheet. Still and surprisingly, i cannot access the element as soon as i start working with variables, like



double temp2 =%(col(i)[j]$);



Can somebody explain which mechanic lies behind this? It seems completeley odd to me at the moment.
mattse123 Posted - 11/08/2017 : 08:17:48 AM
Hello,

first of all, thank you for your answer. It already helped me in a way. I know now that i can acces the imported Data simply by the

wks. ****

commands.

All i need to do now is to check if a row is filled with only zero-entries. Is there a method to acces the value of an element within the worksheet? If that's possible, i can simply check it with a double-for loop and delete the rows filled with zero-entries.

greg Posted - 11/07/2017 : 3:25:36 PM
Not sure what you want with the "minus 10 rows", but there are two row properties in Origin:

// The number of displayed rows in the active worksheet
DisplayRows = wks.nrows;

// The number of rows of data in a column
range ra = [Book1]Sheet1!2; // Second column
DataRows = ra.GetSize();

So you could try:
impasc fname:=strToken$
options.PartImp.Partial:=1
options.PartImp.FirstCol:=2
options.PartImp.LastRow:=$(DataRows - 10)
options.Sparklines:=0
options.Names.AutoNames:=0
options.Names.FNameToSht:=1
options.ImpMode:=1
options.Miscellaneous.LeadingZeros:=1;
for example.

There is no hope!
(But I may be wrong.)

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000