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
 access wks-name
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

bjornh

Sweden
6 Posts

Posted - 06/13/2001 :  08:34:11 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

maybe somebody can help me find a way to specifically adress all worksheets created when importing ascii-files using the option "When non-numeric...Start new worksheet/column".
I need to loop through the new worksheets in order to move all Y-columns to the first worksheet. Im currently running 6.1 SR2

Thanks, Bjorn

CStorey

Canada
137 Posts

Posted - 06/13/2001 :  11:23:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
What I would do is write a LabTalk script that can run from a button or menu.

Here are the basics:

// To get all worksheet names and copy a column

%Z="";
doc -e W {
%Z=%Z %H; //creates a list of all worksheets
};

I would then select those worksheets you wish to extract data from into a separate list and loop over each copying data to a new worksheet. You might want to look at the following commands:

win -n winType [winName] //Create a wks for

[WksName]!wks.joinMode=0; //Set the wks mode to append new columns

[WksName]!wks.colSel(colNum,n) //Select a column

[ToWks]!wks.join(FromWks) //Copy all columns from 1 wks to another

Hope this helps.

Craig Storey
Origin WeRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring&id=1&hub



Edited by - cstorey on 06/13/2001 11:26:57
Go to Top of Page

bjornh

Sweden
6 Posts

Posted - 06/14/2001 :  11:36:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for Your support Craig,

I found an alternative method by setting the import-option "Import as...." in position "As new columns". By doing this all sections of numeric data gets separate columns in one wks. The only problem is that I seem to loose most of the header info because the header label that Ive added is overwritten each time the import routine finds the text-rows that begins every new section of numeric data. Do You know of any way to keep all this text, which I need to access in order to rename the new columns?
Im adding a reduced example of my ascii file:

Time lamsoni_w lamsons_w rl nmot
[s] [-] [-] [%] [Upm]
0.003 0.99561 1.00000 19.5 1160
0.013 0.99414 1.00000 19.5 1160
0.063 0.98999 1.00000 19.5 1160
0.073 0.99121 1.00000 19.5 1160
Time CHAN2
[s] [Lambda]
0.060 1.021
0.214 1.028
0.232 1.028
Time CHAN2
[s] [Lambda]
0.056 1.014
0.074 1.014
0.346 1.035
Time CHAN2
[s] [Lambda]
0.052 1.026
0.070 1.029
0.090 1.032

/Bjorn
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 06/15/2001 :  08:46:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you've managed to put the different data sections into separate columns then you must also have the "When non-numeric is found..." ASCII option set to "Start new worksheet/column". In that case only text at the beginning of the data file is used for column names/labels - subsequent text is discarded. In your example, subsequent text could not have been used for column names anyway because duplicate column names are not allowed.

It sounds like you've accomplished everything you want except for the names and labels. If those are always the same, then the easiest thing to do is to use a worksheet template with columns that are already named and labelled. (Make sure that "Rename columns..." and "Create column labels.." are unchecked in the Other Options for that template.)

If your data file format or labels vary then change the "When non-numeric is found..." setting to "Read as missing data" and make sure that the column display is set for "Text & Numeric". Text fields will then be imported along with the data and you can sort things out later with a LabTalk script. I can't suggest an appropriate script without knowing more about your data.

Finally, Origin Professional gives you much more control over ASCII and binary data import. If you have Origin Pro you should read the File Utilities section of the OriginPro Manual for information.


Mike Buess
Origin WebRing Member
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 06/17/2001 :  11:47:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can download import.zip (3KB), which provides a simple method for importing and labelling data that are formatted as in your example. It contains two worksheet templates (MyData.otw and MyLabels.otw) and a script file (Import.ogs) which should all be copied to your Origin program folder. Import your data with this command:
run.section(Import,Main);
The chosen data file is imported to both worksheet templates. In the MyData worksheet the data sections are separated into separate columns. Text is then extracted from the MyLabels worksheet and assigned to the MyData column labels. (The MyLabels worksheet is deleted afterwards.) The scripts for extracting the labels make the following assumptions about your data file format.
  • Text lines always occur in pairs (Name followed by [unit]).
  • The first data section contains at least two columns.
  • Subsequent data sections contain exactly two columns.
  • There are no missing data values (--) in the first column.
Labels are found by examining the first column of the MyLabels worksheet row-by-row for missing values:
if (col(1)[ii]==0/0) {//then it must be text};
That might take some time if your data files are large. Perhaps someone else can come up with a more efficient method for extracting the text.

Note: I also assumed that the first column in each data section should be an X-column. If that's not the case just delete the following line near the end of Import.ogs:
wo -t ii 4;


I hope this helps,

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 06/17/2001 11:49:12

Edited by - Mike Buess on 06/17/2001 12:30:22
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 06/19/2001 :  09:17:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It occurred to me that the lengths of the data columns indicate exactly where to find the labels. Try import2.zip... it should be much faster.

Mike Buess
Origin WebRing Member
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