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 for Programming
 Forum for Origin C
 Importing ascii 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
symcel Posted - 02/07/2007 : 04:30:14 AM
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.
7   L A T E S T    R E P L I E S    (Newest First)
symcel Posted - 02/08/2007 : 09:32:10 AM
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.
symcel Posted - 02/07/2007 : 10:19:53 AM
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?
Mike Buess Posted - 02/07/2007 : 09:45:30 AM
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
symcel Posted - 02/07/2007 : 07:30:40 AM
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?
Mike Buess Posted - 02/07/2007 : 06:08:41 AM
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
symcel Posted - 02/07/2007 : 05:30:31 AM
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

Mike Buess Posted - 02/07/2007 : 04:56:29 AM
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

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