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
 Forum for Origin C
 Importing ascii file
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

symcel

Sweden
Posts

Posted - 02/07/2007 :  04:30:14 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (7.5):
Operating System: Win XP

I am trying to import an ASCII file into a worksheet and then create a graph. Have tried to adapt this example http://www.originlab.com/forum/topic.asp?TOPIC_ID=5435 but I experience som problems.

- My ascii file starts with one header line and thereafter there are 3 more lines I want to ignore. Then there are data lines.

- Column 1 to 49 are all Y columns and column 50 is the X column (there are also a column 51 with timestamp which is not important)

When I have created the worksheet I want to create a graph using the X-column (col 50) and an one or more arbitrary Y columns.


One problem I have is that when trying to use wks.col<n>.type I get the error: "Error, Variable "wks.col1.type" not declared". I cannot ignore the rows 2 to 4 either.

Mike Buess

USA
3037 Posts

Posted - 02/07/2007 :  04:56:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
1. wks.col1.type is a LabTalk property. Column::SetType is the equivalent Origin C method.

Worksheet wks = Project.ActiveLayer();
wks.Columns(0).SetType(OKDATAOBJ_DESIGNATION_Y); // set 1st col as Y
wks.Columns(49).SetType(OKDATAOBJ_DESIGNATION_X); // set 50th col as X


2. In the example you cited you would use this...

ascimp.iHeaderLines = 4;
ascimp.iSubHeaderLines = 0;
ascimp.iAutoSubHeaderLines = 0;

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 02/07/2007 05:08:26 AM
Go to Top of Page

symcel

Sweden
Posts

Posted - 02/07/2007 :  05:30:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Mike that solved some problems but there still are a few strange things.

The column header in the worksheet now looks like this:
A(Y) B(Y) C1(Y) C2(Y) ... C48(X) C49(Y)

That's strange since the data file looks like this (I have cut out the columns D1 to F8 + an extra special column and all data lines except two).

A1 B1 C1 Time Rel Time
-------------------------------------------------------------------
-51.441762 -30.164956 -44.445234
-------------------------------------------------------------------
58.883708 29.578172 52.50651 0 2007-01-30 01:52:23
65.724284 28.800655 60.202008 15 2007-01-30 01:52:38

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 02/07/2007 :  06:08:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The example you cited does not read the column names from file... ascimp.renameCols=0... but generates default column names instead. If you really want to use the names in file you can try ascimp.renameCols=1.

Mike Buess
Origin WebRing Member
Go to Top of Page

symcel

Sweden
Posts

Posted - 02/07/2007 :  07:30:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
ascimp.iRenameCols = 1 doesn't seem to make any difference. I also don't find any documentation of wks.GetASCIMP, wks.SetASCIMP nor ASCIMP. I am new to Origin and I am looking at the help file accessible from Help->Programming in Origin. Is there any better documentation for somewhere?
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 02/07/2007 :  09:45:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Look in OC_types.h for ASCIMP. However, as I tried to convince the user in the topic you cited, it's often much easier to use a customized template. Just create a worksheet with 52? columns and name them properly. Then select File > Import > ASCII Options and set up the options as described in the other topic, except for Skip main header, number of lines = 4. (Also, make sure all of the Other Options... are unchecked.) Then click the Update Options button and save the template. Now you can import with this and avoid spelling out the ASCIMP properties each time.

Worksheet wks;
wks.Create("templateName.otw");
ASCIMP ascimp;
wks.GetASCIMP(ascimp);
wks.ImportASCII(sa[i], ascimp);

Mike Buess
Origin WebRing Member
Go to Top of Page

symcel

Sweden
Posts

Posted - 02/07/2007 :  10:19:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Unfortunately it's not that static, right now I have 48 + 1 Y columns (named A1 to F8) and 1 Y column + a timeStamp I ignore == 51 columns. But it may also be 96 + 1 X columns + 1 Y column + timestamp.

Besides that it would be great if there were a complete documentation of all the functions and properties of the worksheet and other objects, but perhaps there isn't?
Go to Top of Page

symcel

Sweden
Posts

Posted - 02/08/2007 :  09:32:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have found out that ascimp.renameCols=4 solves my problem. Apparently it means that the column header will be read from the line 4 rows above the first row with data.
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