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
 Help with custom script for importing a file

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
Zisternas Posted - 02/06/2010 : 4:24:15 PM
Origin Ver. and Service Release (Select Help-->About Origin): Origin 8 SR0
Operating System: WinXP

HI everyone!

I am brand new in Origin and have a little mess with some data I want to organize. The data to import looks like this:

Sample File C:\Dokumente und Einstellungen\Desktop\Dp6nm.S0
Model 3080
Model 3085
Inner Radius(cm) 0.00937
Outer Radius(cm) 0.01905
Characteristic Length(cm) 0.04987
Model 3025 High Flow
Gas Viscosity (kg/(m*s)) 1.822e-005
Mean Free Path (m) 6.64201e-008
Channels/Decade 64
Multiple Charge Correction FALSE
Nanoparticle Aggregate Mobility Analysis FALSE
Diffusion Correction FALSE
Units dw/dlogDp
Weight Number
Sample # 18
Date 02/02/10
Start Time 16:10:03
Diameter Midpoint
3.59 0
3.72 0
3.85 0
4.00 0
4.14 0
4.29 0
4.45 0
4.61 0
4.78 0
4.96 0
5.14 0
5.33 0
5.52 0
5.73 0
5.94 0
6.15 0
6.38 0
6.61 9475.11
6.85 40563
7.10 106759
7.37 110751
7.64 115188
7.91 65934
8.20 29574.4
8.51 11368.7
8.82 2391.23
9.14 0
9.47 0
9.82 0
10.2 0
10.6 0
10.9 626.724
11.3 0
11.8 0
12.2 0
12.6 0
Scan Up Time(s) 120
Retrace Time(s) 15
Down Scan First FALSE
Scans Per Sample 1
Impactor Type(cm) None
Sheath Flow(lpm) 15
A Flow(lpm) 1.5
Inlet Flow(lpm) 1.5
Sample Flow(lpm) 0.03
Low Voltage 33.0534
High Voltage 433.781
Lower Size(nm) 3.52269
Upper Size(nm) 12.864
Density(g/cc) 1.2
Title
Status Flag Normal Scan
td(s) 0.336
tf(s) 0.156731
D50(nm) 1000
Median(nm) 7.44934
Mean(nm) 7.47718
Geo. Mean(nm) 7.46478
Mode(nm) 7.63506
Geo. Std. Dev. 1.05894
Total Concentration(#/cm³) 7697.37
Comment

So they mix data with text. I cannot partially import some of the data (the important ones start in line 19 to line 54), because I need the others to perform some calculations.
Up to now I was importing the data with the following script:

WCol(1)[l]$=Diameter particle;
WCol(1)[u]$=nm;

WCol(2)[l]$= measurement;
WCol(2)[u]$= #

//Voltage associated (V)
WCol(3)[l]$=Volt DMA2;
WCol(3)[u]$=V;
WCol(3)[19] = WCol(2)[64];
for (int i=20; i<=54; i++)
WCol(3)[i] = exp(ln(WCol(3)[i-1]) + ln(WCol(2)[65]/WCol(2)[64]) / 35);

//Mobility associated (m^2/Vs)
WCol(4)[l]$=Mobility;
WCol(4)[u]$=m\+(2)/Vs;
for (int i=19; i<=54; i++)
WCol(4)[i]= (ln(WCol(2)[4]/WCol(2)[3])*WCol(2)[60])/(2*PI*WCol(2)[5]*WCol(3)[i]*600);


And also I was opening the file in a template, where the column designation was XYXX, since the 3rd and 4th calculated columns are to be used as X in plots. But at the moment I want to plot 3rd and 2ndcolumn, it gives me an error message: “Your column selection must include associated plot designations”. I have read that this happens when the X column is the rightmost column, so here are my questions:
• How can I change the order of the columns, or import them in some other way to avoid this error? And is there a way to directly create a column with X designation, without the template?
• Could be possible to separate in different columns the values from rows 19 to 54, which are the “to be plotted” ones, and keep the others just to be used for calculations? Or maybe add some code to plot just those values instead of selecting them by hand…
• For normalizing values of column two I have tried to use this code that I found in the forum and then modified by me, but I had error 1600, what did I wrong?
//Normalized
WCol(5)[l]$=Normal ;
ds1 = col(2);
range rd2 = col(5); // target column
// loop over all columns
for( i = 19; i <= 54; i++ )
{
// get stats on col
sum(rd1);
// divide col by max value
rd2 /= sum.max;
}


Sorry for such a long post, and maybe so obvious questions, but I need to learn Origin in short time and sometimes I get lost on manuals.

Thank you very much in advance!
8   L A T E S T    R E P L I E S    (Newest First)
alisonoc Posted - 04/01/2010 : 03:22:03 AM
Easwar thanks a million for the link it looks very interesting. It would certainly save alot of time if this was possible however due to limits on the licensing of origin (we only have 10 floating licences) it isnt really an option to put it on a computer in the lab where it would not be regularly used. I'm working with several people at the moment to build a custom code. Hopefully that will work out but I appreciate your reply thanks!
easwar Posted - 03/28/2010 : 10:21:31 AM
Hi Alison,

Your data appears to be generated by a LabVIEW vi/application? You could modify the VI to directly push data into Origin from LabVIEW, see this page for starters:
http://originlab.com/index.aspx?s=8&lm=174

If on the other hand the data does need to be imported from already-created files, looks like some custom import coding needs to be done, you can contact tech support for further details, refer to this post.

Easwar
OriginLab
alisonoc Posted - 03/26/2010 : 10:54:34 AM
Hello everyone I have a similar problem to the one discussed by Zisternas. I have no experience with origin and no programming experience. My data is imported as follows:

LabVIEW Measurement
Writer_Version 0.92
Reader_Version 1
Separator Tab
Multi_Headings Yes
X_Columns No
Time_Pref Absolute
Operator zwick
Date 2010/03/17
Time 18:10:54.329432
***End_of_Header***

Channels 6
Samples 10 10 10 10 10 10
Date 2010/03/17 2010/03/17 2010/03/17 2010/03/17 2010/03/17 2010/03/17
Time 18:10:55.229429 18:10:55.229429 18:10:55.229429 18:10:55.229429 18:10:55.229429 18:10:55.229429
Y_Unit_Label Strain Strain Strain Strain Strain Strain
X_Dimension Time Time Time Time Time Time
X0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0
Delta_X 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000
***End_of_Header***
X_Value temp1 temp2 temp3 Strain1 Strain2 Strain3 Comment
-0.000258 -0.000213 0.004083 -0.000430 -0.000526 -0.001156
-0.000259 -0.000213 0.004083 -0.000429 -0.000527 -0.001156
-0.000259 -0.000214 0.004083 -0.000430 -0.000527 -0.001156
-0.000259 -0.000214 0.004083 -0.000430 -0.000527 -0.001156
-0.000259 -0.000214 0.004083 -0.000429 -0.000527 -0.001156
-0.000259 -0.000213 0.004083 -0.000429 -0.000527 -0.001156
-0.000259 -0.000214 0.004083 -0.000429 -0.000527 -0.001156
-0.000259 -0.000214 0.004083 -0.000430 -0.000527 -0.001156
-0.000259 -0.000214 0.004083 -0.000430 -0.000527 -0.001156
-0.000258 -0.000213 0.004083 -0.000430 -0.000527 -0.001156

Channels 6
Samples 10 10 10 10 10 10
Date 2010/03/17 2010/03/17 2010/03/17 2010/03/17 2010/03/17 2010/03/17
Time 18:10:56.229429 18:10:56.229429 18:10:56.229429 18:10:56.229429 18:10:56.229429 18:10:56.229429
Y_Unit_Label Strain Strain Strain Strain Strain Strain
X_Dimension Time Time Time Time Time Time
X0 1.0000000000000000E+0 1.0000000000000000E+0 1.0000000000000000E+0 1.0000000000000000E+0 1.0000000000000000E+0 1.0000000000000000E+0
Delta_X 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000
***End_of_Header***
X_Value temp1 temp2 temp3 Strain1 Strain2 Strain3 Comment
-0.000259 -0.000213 0.004083 -0.000430 -0.000527 -0.001156
-0.000258 -0.000213 0.004083 -0.000430 -0.000527 -0.001156
-0.000258 -0.000213 0.004083 -0.000430 -0.000527 -0.001156
-0.000259 -0.000213 0.004083 -0.000429 -0.000527 -0.001156
-0.000258 -0.000213 0.004083 -0.000430 -0.000527 -0.001157
-0.000258 -0.000213 0.004083 -0.000430 -0.000527 -0.001157
-0.000259 -0.000214 0.004083 -0.000430 -0.000527 -0.001157
-0.000259 -0.000213 0.004083 -0.000429 -0.000527 -0.001157
-0.000259 -0.000214 0.004083 -0.000430 -0.000527 -0.001157
-0.000259 -0.000214 0.004083 -0.000430 -0.000527 -0.001156

Channels 6
Samples 10 10 10 10 10 10
Date 2010/03/17 2010/03/17 2010/03/17 2010/03/17 2010/03/17 2010/03/17
Time 18:10:57.231429 18:10:57.231429 18:10:57.231429 18:10:57.231429 18:10:57.231429 18:10:57.231429
Y_Unit_Label Strain Strain Strain Strain Strain Strain
X_Dimension Time Time Time Time Time Time
X0 2.0000000000000000E+0 2.0000000000000000E+0 2.0000000000000000E+0 2.0000000000000000E+0 2.0000000000000000E+0 2.0000000000000000E+0
Delta_X 0.100000 0.100000 0.100000 0.100000 0.100000 0.100000
***End_of_Header***
X_Value temp1 temp2 temp3 Strain1 Strain2 Strain3 Comment
-0.000259 -0.000214 0.004083 -0.000430 -0.000526 -0.001156
-0.000259 -0.000214 0.004083 -0.000430 -0.000527 -0.001156
-0.000259 -0.000214 0.004083 -0.000429 -0.000527 -0.001157
-0.000259 -0.000213 0.004083 -0.000429 -0.000527 -0.001156
-0.000259 -0.000214 0.004083 -0.000430 -0.000527 -0.001157
-0.000259 -0.000214 0.004083 -0.000430 -0.000527 -0.001157
-0.000259 -0.000213 0.004083 -0.000430 -0.000527 -0.001157
-0.000259 -0.000214 0.004083 -0.000430 -0.000527 -0.001157
-0.000259 -0.000214 0.004083 -0.000429 -0.000527 -0.001156
-0.000259 -0.000213 0.004083 -0.000429 -0.000527 -0.001156

The problem I have is that origin needs to search through the cells and find the cell with "Time" it then needs to select the cell below that and take that value and put it under "X_Value" (in origin the cells underneath do not hold values) so that the time is in the column next to my temperature and strain measurements. It then needs to select the time, temperature and strain (7) columns and then paste those into another workbook. There is over 8 million rows of data so there is no chance of being able to do this by hand. I then plan (in the new workbook with uninterrupted data) to remove duplicate data. Hopefully the remaining data will be small enough to fit into excel as I have a second data set which needs to be merged with this set based on time!

I'm terribly stuck and would really really really appreciate ANY help, ive already asked everyone I work with along with friends and family and no one seems able to do this. Please help!

Thanks,

Alison.
Laurie Posted - 03/01/2010 : 12:10:27 PM
newsheet is an x-function:
http://www.originlab.com/WWW/HELPONLINE/ORIGIN/EN/PROGRAMMING/mergedProjects/X-Function/X-Function/Newsheet.html

you can use the following:
newsheet name:="Copy of %(layer.name$)";

layer.name$ returns the name of the active sheet, so the new sheet added will be named copy of...

You cannot have two sheets with the same name.

OriginLab Technical Support
Zisternas Posted - 02/16/2010 : 11:02:38 AM
You are right Greg, I was not taking into account the first row where the path of the file is indicated. I realised short after writing here.

For the plot I am using the plot tool of the program, since i have to compare several sheets from different worksheets. I think it will take me less time than figuring out a code to select each time the columns I need.

Thanks for everything and I will keep woorking on it!

EDIT: by the way, how could I rename the new sheets with the same name as the previous one?

I am importing sets of 4 or more sheets to which I apply the previous script, but they are created with the generic name "Sheet1, 2, 3..". I would like them to have the same name as the original ones(or be named as "Copy of..."), since they are classified by this name.

I have tried with the Worksheet -d wksName, -dr and -da, but the new sheets doesn't appear.

Thanks in advance!
greg Posted - 02/12/2010 : 11:26:54 AM
Your column C calculation depends on the lowVol variable which you read from col(3)[SizeAll-17] of the imported data, but if 'Comment' is the last row and Low Voltage is the value you meant to read, then the correct value should be col(3)[SizeAll-16].

To answer your earlier question about plotting -
The column plot designations are only required if you use column selection for plotting. With no column selected, the Plot Setup dialog allows arbitrary column plot designation. The plotxy X-Function can do the same thing. For example, you can plot column 3 as X vs column 2 as Y with
plotxy (3,2);
See the plotxy help for more options.
Zisternas Posted - 02/11/2010 : 11:50:14 AM
Hi Larry. Thank you very much, your example works fine, but since the total number of data rows is not fixed (but the text rows before and after the data is) I have tried to add some flexibility to the code:

// Range to access a column
range sx = col(1);
range sy = col(2);
//number of data rows
int SizeAll = sx.GetSize();
int SizeDataEnd = SizeAll - 26;
// Get one value
double lowVol = col(3)[SizeAll-17];
// Create a new worksheet
newsheet cols:=3;
// Set the column type to X
wks.col3.type = 4;
// Copy data
for(int ii = 20; ii<=SizeDataEnd; ii++)
{
col(a)[ii-19] = sx[ii];
col(b)[ii-19] = sy[ii];
}
// Do calculation
col(c) = col(b)*lowVol;


but col(c) is not showing any value, is not rigth to select the row of lowVol like I did?

Thanks in advance!
larry_lan Posted - 02/08/2010 : 04:49:06 AM
Hi:

It's difficult to extract information from such file since there are text before and after the data. I think maybe you can import the whole file as text and then read data into a new workbook/worksheet. Such as:

1>



2>



3>



So, the file was Delimited by space. After imported, you can create a new workbook and write some script to reorganize the data. Basically, you should not put text and number in the same column (That's why sum(rd1) returns error in your code).

For example, you can do this after import:

// Range to access a column
range sx = col(1);
range sy = col(2);
// Get one value
double lowVol = col(3)[64];
// Create a new worksheet
newsheet cols:=3;
// Set the column type to X
wks.col3.type = 4;
// Copy data
for(int ii = 19; ii<=54; ii++)
{
	col(a)[ii-18] = sx[ii];
	col(b)[ii-18] = sy[ii];
}
// Do calculation
col(c) = col(b)*lowVol;


Thanks
Larry

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