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
 Template for Workbook?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

b.franze

Germany
1 Posts

Posted - 08/30/2012 :  04:43:51 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.5G
Operating System: Win XP

Dear all,
I am working in a analytical chemistry lab and am dealing with lots of data files. Due to instrument export features I am only able to export my measured data with x and y values following each other in ONE column, like this:

column1

time0
time1
time2

value0
value1
value2

as I need to have those data in 2 columns I am looking for a way to handle lots of those raw data files in one click. By now I need to add each column manually and calculate the column values into this new column in order to get the typical form like this:

column1 column2
time0 value0
time1 value1

Is there any possibility to write a template for this purpose like it is the case for a diagram in the design manager?

I appreciate any help. Thank you in advance.

Hideo Fujii

USA
1582 Posts

Posted - 08/30/2012 :  10:46:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi b.franze,

You can put your script to the "Script Panel" of a (3-column) worksheet (right-click in the gray area in the worksheet, and choose "Show Script Panel" shortcut), then save it as a worksheet template. Sample script may be like as follows:

delete col(3);
delete col(2);
worksheet -a 2;
range c1=col(1);
range c2=col(2);
range c3=col(3);
nr=c1.getSize(); //number of rows
range r1=col(1)[1:$(nr/2)];    //1st half
range r2=col(1)[$(nr/2+1):nr]; //2nd half
c2=r1;  //copy 1st harf
c3=r2;  //copy 2nd half

When you open this template from the Template Library, the Script Panel with the code should appear. If you enter the data in the first column, and press "Execute All" button in the panel, it performs accordingly. (Note: Be aware that the bottom part of the data doesn't contain rows of missing values.)

Hope this helps.

--Hideo Fujii
OriginLab
Go to Top of Page

Drbobshepherd

USA
Posts

Posted - 08/30/2012 :  11:15:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
For this task, I reccommend an Import Filter with a LabTalk script.

Use the Import Wizard to create an import filter for your data. Check "Save Filter" on the Save Filters page of the Import Wizard window, then check "Specify advanced filter options". Enter the following lines:

ii=wks.maxrows/2+1; // 1st value row number.
jj=wks.maxrows; // Last value row number.
%A=$(ii); // Convert to string register.
%B=$(jj); // Convert to string register.
range y1=col(A)[%A:%B]; // Declare range for y-values.
col(B)=y1; // Copy y-values to col(B).
wks.nrows=wks.maxrows/2; // Delete unnecessary rows.

Then click on "Finish". The file should import and the data will automatically transfer to col(B). I am assuming column1 is written to the column heading, so col(A) contains time-values stacked on top of your y-values, no blank cells. You can adjust the index values for ii and jj if you need to.

Once you get the import filter working the way you want, try dragging and dropping your files from a MS directory window into the Origin Workspace. This is a very efficient way to process a lot of files.

Let me know if this works for you.

DrBobShepherd
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