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
 How to import data into various XY column pairs
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

redman

UK
59 Posts

Posted - 11/24/2008 :  09:19:24 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I just got a lot of mass spectra data (ASCII) with only two columns. But the data contain varous XY pairs seperated with non-numeric text "cyclying times". I tried to import one data file into an Origin project by import wizard by setting "Column designations" to "XY XY" in the Impot Wizard-Data Columns tab and "Non-numberic data in a numeric field" to "Start new column" in the Data selection tab, and saved the filter as well as the worksheet template , but I experienced the following problem when I tried to import other data files based on the above mentioned filter and template:

1. If the XY columns are more than that of the template, all the rest data will be imported as Y columns rather than XY pairs. By the way, the template was manually set into XY column pairs.
2. If the XY columns are less than that of the template, empty XY columns will also be created.

My questions are:

1. Is it possible to import all the data into XY column pairs disregarding the data pair number.
2. Furthermore, only import the first X column, and ignore all other X columns, or delete all other X columns afterwards by a script file.
3. More generally, how to find empty columns in different worksheets/workbooks, and delete all the empty ones by a script file.

Could please anybody give me an answer or some suggestions?
Thanks in advance.

Redman

Deanna

China
Posts

Posted - 11/24/2008 :  10:59:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Redman,

The problem is that the number of columns were set to a fixed number and remembered in the import filter.

You can try to reset the filter with the Import Wizard again. In the Data Columns page, you can try to set the Column Designations to XY XY and then click Apply. Also, enter 0 after Number of Columns and then click Apply.



By doing this, the Import Wizard will automatically determine the number of columns in the data file and apply the plotting designations to XY XY... when you use the filter.

Note: to modify and resave the filter, open the Import Wizard, choose this filter to import a file, modify the settings in each page of the wizard as you need and then save it on the last page of the wizard.

quote:
2. Furthermore, only import the first X column, and ignore all other X columns, or delete all other X columns afterwards by a script file.

For this question, you can try the following script:

ncol = wks.nCols;
for (ii=ncol; ii>1; ii--)
{
	if (wks.col$(ii).type == 4) del col($(ii));
};


You can even put it in in the Advanced Options page of the Import Wizard and save it with the import filter. (See details here: http://www.originlab.com/www/helponline/Origin8/en/origin.htm#importing_and_exporting/import_wizard,_advanced_options_page.htm)

quote:
3. More generally, how to find empty columns in different worksheets/workbooks, and delete all the empty ones by a script file.

Maybe you don't need this with a proper filter, right? If you still need this script, please tell us which version of Origin you are using.

Deanna
OriginLab Technical Services

Edited by - Deanna on 11/24/2008 11:02:23 AM
Go to Top of Page

redman

UK
59 Posts

Posted - 11/25/2008 :  05:28:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Deanna, thank you very much for your suggestions. However, it seems that the filter doesn't work for me. Here I copied partially the data to show its structure:

Scan Cycle Time ms
1 1 0:00:00 2
amu c/s
0.4 200
0.42 300
0.44 0
0.46 100
0.48 0
0.5 200
Scan Cycle Time ms
1 2 0:00:42 42334
amu c/s
0.4 0
0.42 100
0.44 0
0.46 0
0.48 100
0.5 0
Scan Cycle Time ms
1 3 0:01:24 84667
amu c/s
0.4 0
0.42 0
0.44 0
0.46 100
0.48 100
0.5 100
Scan Cycle Time ms
1 4 0:02:07 127024
amu c/s
0.4 100
0.42 100
0.44 0
0.46 100
0.48 100
0.5 100
Scan Cycle Time ms
1 5 0:02:49 169356
amu c/s
0.4 100
0.42 0
0.44 0
0.46 100
0.48 0
0.5 0

As the original data contain only two columns, the filter can only import the "first Cycle data" into XY pairs, and all the rest data into Y columns, see the attached images..

By the way, I use OriginPro 8.0 SR4, Windows XP home. If possible, could you please tell me how to find and delete empty columns in any worksheet/workbooks?

At present, I try to import each data file into a origin worksheet/book, and than use scripts to delete all other Y columns which should be X columns except the first X columns, finally set the column type and numerictype to numeric and float 4, respectively. This seems OK, but not convinient.

Best regards,
Go to Top of Page

Deanna

China
Posts

Posted - 11/25/2008 :  10:28:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry, I overlooked something in your original post. My method cannot apply.

I think we do need to use script to set the column designation and removing the columns you don't want. But the script can be saved with the filter so that it is automatically executed after the import is done. This should be more convenient.

As for deleting the empty columns, please try the following:

colcount = wks.ncols;

for (ii=colcount; ii>=1; ii--)
{
	double temp;
	get col($(ii)) -e temp;
	if (temp==0) del col($(ii));
}


Deanna
OriginLab Technical Services
Go to Top of Page

redman

UK
59 Posts

Posted - 11/25/2008 :  11:20:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot. It works fine now by using scripts saved in the filter:
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